List of usage examples for android.os Bundle get
@Nullable
public Object get(String key)
From source file:no.ntnu.idi.socialhitchhiking.myAccount.MyAccountCar.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); int px = convertDpToPixel(160, getApp()); if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { if (data.getData() == null) { Bundle extras = data.getExtras(); btm = (Bitmap) extras.get("data"); } else if (data.getAction() != null) { btm = getBitmap(data.getData(), px, px); }//from w w w . j av a2s . co m if (btm != null) { imageView.setImageBitmap(btm); imageView.invalidate(); carChanged = true; } } else if (requestCode == ALBUM_REQUEST && resultCode == RESULT_OK) { btm = getBitmap(data.getData(), px, px); if (btm != null) { imageView.setImageBitmap(btm); imageView.invalidate(); carChanged = true; } } }
From source file:androidx.media.MediaUtils2.java
/** * Creates a {@link MediaMetadataCompat} from the {@link MediaMetadata2}. * * @param metadata2 A {@link MediaMetadata2} object. * @return The newly created {@link MediaMetadataCompat} object. *//*from w w w .j a v a 2 s .co m*/ MediaMetadataCompat createMediaMetadataCompat(MediaMetadata2 metadata2) { if (metadata2 == null) { return null; } MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); List<String> skippedKeys = new ArrayList<>(); Bundle bundle = metadata2.toBundle(); for (String key : bundle.keySet()) { Object value = bundle.get(key); if (value instanceof CharSequence) { builder.putText(key, (CharSequence) value); } else if (value instanceof Rating2) { builder.putRating(key, createRatingCompat((Rating2) value)); } else if (value instanceof Bitmap) { builder.putBitmap(key, (Bitmap) value); } else if (value instanceof Long) { builder.putLong(key, (Long) value); } else { // There is no 'float' or 'bundle' type in MediaMetadataCompat. skippedKeys.add(key); } } MediaMetadataCompat result = builder.build(); for (String key : skippedKeys) { Object value = bundle.get(key); if (value instanceof Float) { // Compatibility for MediaMetadata2.Builder.putFloat() result.getBundle().putFloat(key, (Float) value); } else if (METADATA_KEY_EXTRAS.equals(value)) { // Compatibility for MediaMetadata2.Builder.setExtras() result.getBundle().putBundle(key, (Bundle) value); } } return result; }
From source file:com.tomdignan.jiffymonitor.ChartFragment.java
@Override public void onActivityCreated(Bundle inState) { super.onActivityCreated(inState); if (inState != null) { PersistentState state = (PersistentState) inState.get(STATE_CHART); Loggy.i(TAG, "onActivityCreated: restoring chart view state"); this.chartView.restoreState(state); } else {//from ww w. j av a 2s. co m Loggy.i(TAG, "onActivityCreated: got null bundle"); } }
From source file:ca.ualberta.cs.swapmyride.View.AddInventoryActivity.java
/** * After returning from the camera activity, get the photo information * and send it into the structure to get it ready. *//* w w w.j a v a 2 s .co m*/ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); Photo photo = new Photo(imageBitmap); ImageView newImage = new ImageView(getApplicationContext()); newImage.setImageBitmap(photo.getImage()); newImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); newImage.setAdjustViewBounds(true); //gallery.removeAllViews(); gallery.addView(newImage); photos.add(photo); } }
From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java
private void handleExtra(Intent intent) { Bundle extras = intent.getExtras(); if (extras != null && extras.size() > 0) { for (String k : extras.keySet()) { Log.i(TAG, "k = " + k + " : " + extras.getString(k)); }/* w w w .j av a 2s. co m*/ } if (extras != null && "dialog".equals(extras.get("_extra1"))) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle("" + extras.get("_extra2")); alertDialogBuilder.setMessage("" + extras.get("_extra3")).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialogBuilder.create().show(); } }
From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java
@Override public void onEvent(int eventType, Bundle params) { switch (eventType) { case EVENT_ERROR: String reason = params.get("reason") + ""; showToast("EVENT_ERROR: " + reason); break;//from w w w . j a va 2 s . co m case VoiceRecognitionService.EVENT_ENGINE_SWITCH: int type = params.getInt("engine_type"); showToast("*?" + (type == 0 ? "" : "")); break; } }
From source file:com.nextgis.mobile.InputPointActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //get location from calling class Bundle extras = getIntent().getExtras(); if (extras != null) m_CurrentLocation = (Location) extras.get(MainActivity.LOACTION_HINT); setContentView(R.layout.input_point); // setup action bar for tabs final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); actionBar.setHomeButtonEnabled(false); m_Adapter = new FragmentRollAdapter(getSupportFragmentManager()); m_Adapter.setActionBar(actionBar);/*from w w w. j a va2 s . c om*/ m_Pager = (ViewPager) findViewById(R.id.pager); m_Pager.setAdapter(m_Adapter); m_Pager.setOnPageChangeListener(new OnPageChangeListener() { public void onPageScrollStateChanged(int arg0) { } public void onPageScrolled(int arg0, float arg1, int arg2) { } public void onPageSelected(int arg0) { Log.d("ViewPager", "onPageSelected: " + arg0); if (descriptfrag != null) descriptfrag.onStoreValues(); if (positionfrag != null) positionfrag.onStoreValues(); if (camfrag != null) camfrag.onStoreValues(); if (notefrag != null) notefrag.onStoreValues(); actionBar.getTabAt(arg0).select(); } }); Tab tab = actionBar.newTab().setText(R.string.tabs_description_tab) .setTabListener(new TabListener<SherlockFragment>(0 + "", m_Pager)); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tabs_position_tab) .setTabListener(new TabListener<SherlockFragment>(1 + "", m_Pager)); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tabs_camera_tab) .setTabListener(new TabListener<SherlockFragment>(2 + "", m_Pager)); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tabs_note_tab) .setTabListener(new TabListener<SherlockFragment>(3 + "", m_Pager)); actionBar.addTab(tab); }
From source file:com.wareninja.android.opensource.oauth2login.common.Utils.java
/** * Connect to an HTTP URL and return the response as a string. * // ww w. j a va2s. c o m * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url - the resource to open: must be a welformed URL * @param method - the HTTP method to use ("GET", "POST", etc.) * @param params - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String * @throws MalformedURLException - if the URL format is invalid * @throws IOException - if a network problem occurs */ public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } if (AppContext.DEBUG) Log.d("Facebook-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { /* if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } */ // YG: added this to avoid fups byte[] byteArr = null; try { byteArr = (byte[]) params.get(key); } catch (Exception ex1) { } if (byteArr != null) dataparams.putByteArray(key, byteArr); } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } if (AppContext.DEBUG) Log.d("Facebook-Util", method + " response: " + response); return response; }
From source file:it.angelic.soulissclient.fragments.TagDetailFragment.java
@Override public void onCreate(Bundle savedInstanceState) { opzioni = SoulissApp.getOpzioni();/*from w ww . jav a 2 s .c om*/ if (opzioni.isLightThemeSelected()) getActivity().setTheme(R.style.LightThemeSelector); else getActivity().setTheme(R.style.DarkThemeSelector); super.onCreate(savedInstanceState); Bundle extras = getActivity().getIntent().getExtras(); // recuper nodo da extra if (extras != null && extras.get("TAG") != null) tagId = (long) extras.get("TAG"); initDataset(getActivity()); }
From source file:com.newtifry.android.remote.BackendClient.java
private String getAuthToken(Context context, Account account) throws PendingAuthException { String authToken = null;/* w ww. j a v a 2 s . c om*/ AccountManager accountManager = AccountManager.get(context); try { AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, "ah", false, null, null); Bundle bundle = future.getResult(); authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); // User will be asked for "App Engine" permission. if (authToken == null) { // No authorization token - will need to ask permission from user. Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT); if (intent != null) { // User input required context.startActivity(intent); throw new PendingAuthException("Asking user for permission."); } } } catch (OperationCanceledException e) { Log.d(TAG, e.getMessage()); } catch (AuthenticatorException e) { Log.d(TAG, e.getMessage()); } catch (IOException e) { Log.d(TAG, e.getMessage()); } return authToken; }