List of usage examples for android.os Bundle get
@Nullable
public Object get(String key)
From source file:org.inftel.ssa.mobile.ui.fragments.ProjectEditFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.ssa_project_edit, container, false); title = (EditText) view.findViewById(R.id.project_edit_title); summary = (EditText) view.findViewById(R.id.project_edit_summary); description = (EditText) view.findViewById(R.id.project_edit_description); started = (EditText) view.findViewById(R.id.project_edit_started); finished = (EditText) view.findViewById(R.id.project_edit_finished); company = (EditText) view.findViewById(R.id.project_edit_company); license = (EditText) view.findViewById(R.id.project_edit_license); started.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a2 s .co m*/ public void onClick(View v) { DateDialogFragment.newInstance(v.getContext(), started) .show(getActivity().getSupportFragmentManager(), "Date Picker Dialog"); } }); finished.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DateDialogFragment.newInstance(v.getContext(), finished) .show(getActivity().getSupportFragmentManager(), "Date Picker Dialog"); } }); Bundle arguments = getArguments(); if (arguments != null && arguments.get("_uri") != null) { mContentUri = (Uri) arguments.get("_uri"); } return view; }
From source file:org.anoopam.main.anoopamvideo.VideoListActivity.java
private void processIntent() { if (getIntent() != null && getIntent().getExtras() != null) { Bundle b = getIntent().getExtras(); if (b.get(VIDEO_LIST) != null) { videoDetails = (ContentValues) b.get(VIDEO_LIST); }//from w w w . j a va2 s . c o m if (b.getString(ALBUM_NAME) != null) { currentAlbumName = b.getString(ALBUM_NAME); } } }
From source file:app.android.kopper.selectmaparea.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { try {/* www . j a v a 2s. c om*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); final GoogleMap map = mapFragment.getMap(); //todo: map is null when no internet connection ?? if (map != null) { map.getUiSettings().setCompassEnabled(false); map.getUiSettings().setZoomControlsEnabled(true); map.getUiSettings().setIndoorLevelPickerEnabled(false); map.getUiSettings().setRotateGesturesEnabled(false); map.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() { @Override public void onMapLongClick(LatLng latLng) { createMarker(latLng, map); } }); findViewById(R.id.done_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LinkedList<LatLng> positions = getPositions(); if (positions.size() != 2) Toast.makeText(getApplicationContext(), getString(R.string.error_two_points), Toast.LENGTH_SHORT).show(); else { Intent data = getOrCreateIntent(); data.putExtra(SELECTED_POSITIONS, positions); Serializable nextPage = data .getSerializableExtra(MapActivity.class.getCanonicalName() + "-next"); if (nextPage != null) { try { Intent ii = new Intent(getApplicationContext(), (Class<?>) nextPage); ii.putExtras(data); startActivityForResult(ii, WIZARD_RESULT_CODE); } catch (Exception e) { LogUtil.e(e); } } else { setResult(RESULT_OK, data); finish(); } } } }); LinkedList<LatLng> positions = (LinkedList<LatLng>) getLastCustomNonConfigurationInstance(); if (positions != null) { for (int a = 0; a < positions.size(); a++) { createMarker(positions.get(a), map); } } else { Intent intent = getOrCreateIntent(); Bundle extras = intent.getExtras(); List<LatLng> selectedPoints = (List<LatLng>) extras.get(SELECTED_POSITIONS); if (selectedPoints != null) for (LatLng pos : selectedPoints) createMarker(pos, map); map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition arg0) { map.setOnCameraChangeListener(null); if (markers.size() == 2) map.moveCamera(CameraUpdateFactory.newLatLngBounds(new LatLngBounds( markers.get(0).getPosition(), markers.get(1).getPosition()), 40)); if (markers.size() == 1) map.moveCamera(CameraUpdateFactory.newLatLngZoom(markers.get(0).getPosition(), 10)); } }); } } else { //no map ((TextView) findViewById(R.id.message)).setText(getString(R.string.error_map_load)); } } catch (Exception e) { LogUtil.e(e); } }
From source file:com.example.ishita.administrativeapp.WatchmanActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nav_drawer); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w . j a v a 2s . c o m toolbar.setTitleTextColor(Color.WHITE); personalData = new PersonalData(this); loadToast = new LoadToast(this); loadToast.setTranslationY(150); loadToast.setBackgroundColor(Color.WHITE).setProgressColor(Color.parseColor("#FF4081")) .setTextColor(Color.BLACK); Bundle bundle = getIntent().getExtras(); GET_URL = (String) bundle.get("GET_URL"); list = (ListView) findViewById(R.id.list); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe); adapter = new WatchmanAdapter(this, items, loadToast, GET_URL); list.setAdapter(adapter); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refresh(); } }); mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.colorAccent, R.color.colorAccent, R.color.colorAccent); mSwipeRefreshLayout.setRefreshing(true); fetchData(); mSwipeRefreshLayout.setRefreshing(false); }
From source file:com.maxxsol.doktorderki.gcm.COGcmListenerService.java
/** * Called when message is received./*from w w w . j ava2 s . c o m*/ * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String consultId = data.getString("consultId"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + consultId); for (String key : data.keySet()) { Log.d("Bundle Debug", key + " = \"" + data.get(key) + "\""); } sendNotification(consultId); /*if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. }*/ // [START_EXCLUDE] // [END_EXCLUDE] }
From source file:org.linkdroid.PostJob.java
/** * Posts the data to our webhook.//from w w w. j a v a 2s. c o m * * The HMAC field calculation notes: * <ol> * <li>The Extras.HMAC field is calculated from all the non Extras.STREAM * fields; this includes all the original bundle extra fields, plus the * linkdroid fields (e.g Extras.STREAM_MIME_TYPE, and including * Extras.STREAM_HMAC); the NONCE is NOT prepended to the input since it will * be somewhere in the data bundle.</li> * <li>The Extras.STREAM_HMAC field is calculated by digesting the concat of * the NONCE (first) and the actual binary data obtained from the * EXTRAS_STREAM uri; this STREAM_HMAC field (along with the other * Extras.STREAM_* fields) are added to the data bundle, which will also be * hmac'd.</li> * <li>If no hmac secret is set, then the NONCEs will not be set in the upload * </li> * </ol> * * @param contentResolver * @param webhook * @param data * @throws UnsupportedEncodingException * @throws IOException * @throws InvalidKeyException * @throws NoSuchAlgorithmException */ public static void execute(ContentResolver contentResolver, Bundle webhook, Bundle data) throws UnsupportedEncodingException, IOException, InvalidKeyException, NoSuchAlgorithmException { // Set constants that may be used in this method. final String secret = webhook.getString(WebhookColumns.SECRET); // This is the multipart form object that will contain all the data bundle // extras; it also will include the data of the extra stream and any other // extra linkdroid specific field required. MultipartEntity entity = new MultipartEntity(); // Do the calculations to create our nonce string, if necessary. String nonce = obtainNonce(webhook); // Add the nonce to the data bundle if we have it. if (nonce != null) { data.putString(Extras.NONCE, nonce); } // We have a stream of data, so we need to add that to the multipart form // upload with a possible HMAC. if (data.containsKey(Intent.EXTRA_STREAM)) { Uri mediaUri = (Uri) data.get(Intent.EXTRA_STREAM); // Open our mediaUri, base 64 encode it and add it to our multipart upload // entity. ByteArrayOutputStream baos = new ByteArrayOutputStream(); Base64OutputStream b64os = new Base64OutputStream(baos); InputStream is = contentResolver.openInputStream(mediaUri); byte[] bytes = new byte[1024]; int count; while ((count = is.read(bytes)) != -1) { b64os.write(bytes, 0, count); } is.close(); baos.close(); b64os.close(); final String base64EncodedString = new String(baos.toByteArray(), UTF8); entity.addPart(Extras.STREAM, new StringBody(base64EncodedString, UTF8_CHARSET)); // Add the mimetype of the stream to the data bundle. final String mimeType = contentResolver.getType(mediaUri); if (mimeType != null) { data.putString(Extras.STREAM_MIME_TYPE, mimeType); } // Do the hmac calculation of the stream and add it to the data bundle. // NOTE: This hmac string will be included as part of the input to the // other Extras hmac. if (shouldDoHmac(webhook)) { InputStream inputStream = contentResolver.openInputStream(mediaUri); final String streamHmac = hmacSha1(inputStream, secret, nonce); inputStream.close(); data.putString(Extras.STREAM_HMAC, streamHmac); Log.d(TAG, "STREAM_HMAC: " + streamHmac); } } // Calculate the Hmac for all the items by iterating over the data bundle // keys in order. if (shouldDoHmac(webhook)) { final String dataHmac = calculateBundleExtrasHmac(data, secret); data.putString(Extras.HMAC, dataHmac); Log.d(TAG, "HMAC: " + dataHmac); } // Dump all the data bundle keys into the form. for (String k : data.keySet()) { Object value = data.get(k); // If the value is null, the key will still be in the form, but with // an empty string as its value. if (value != null) { entity.addPart(k, new StringBody(value.toString(), UTF8_CHARSET)); } else { entity.addPart(k, new StringBody("", UTF8_CHARSET)); } } // Create the client and request, then populate it with our multipart form // upload entity as part of the POST request; finally post the form. final String webhookUri = webhook.getString(WebhookColumns.URI); final HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(USER_AGENT_KEY, USER_AGENT); final HttpPost request = new HttpPost(webhookUri); request.setEntity(entity); HttpResponse response = client.execute(request); switch (response.getStatusLine().getStatusCode()) { case HttpStatus.SC_OK: case HttpStatus.SC_CREATED: case HttpStatus.SC_ACCEPTED: break; default: throw new RuntimeException(response.getStatusLine().toString()); } }
From source file:com.hscardref.android.view.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == WIN_MODEL_REQUEST_CODE) { if (resultCode == RESULT_OK) { Bundle mBundle = intent.getBundleExtra("CardCompositeFilter"); CardCompositeFilter cardCompositeFilter = (CardCompositeFilter) mBundle .get("com.hscardref.generic.domain.CardCompositeFilter"); NodeSelectorFragment nodeSelectorFragment = (NodeSelectorFragment) getSupportFragmentManager() .findFragmentById(R.id.nodeselector); if (nodeSelectorFragment != null) { nodeSelectorFragment.setRefresh(false); // Call a method in the NodeSelectorFragment to search card // info nodeSelectorFragment.applyCardFilter(-2, 0, cardCompositeFilter); }/*from w ww . j a v a2 s . c o m*/ WorkareaFragment workareaFragment = (WorkareaFragment) getSupportFragmentManager() .findFragmentById(R.id.workarea); if (cardCompositeFilter.getAbilities().size() > 0 || cardCompositeFilter.getRaces().size() > 0 || cardCompositeFilter.getTypes().size() > 0) { workareaFragment.setFilterDialogStatus(false); } else { workareaFragment.setFilterDialogStatus(true); } } } }
From source file:com.noswap.keyring.MainActivity.java
public void doGCMStuff() { GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); final String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { Log.v(TAG, "Registering"); GCMRegistrar.register(this, SENDER_ID); } else {//from ww w . j av a 2s. c o m Log.v(TAG, "Already registered: " + regId); } AccountManager am = AccountManager.get(this); Account[] accounts = am.getAccountsByType("com.google"); for (Account account : accounts) { Log.v(TAG, "Account: " + account.name + " (" + account.type + ")"); } if (accounts.length > 0) { Account account = accounts[0]; Bundle options = new Bundle(); am.getAuthToken(account, "Keyring", options, this, new AccountManagerCallback<Bundle>() { @Override public void run(AccountManagerFuture<Bundle> result) { try { Bundle bundle = result.getResult(); String token = bundle.getString(AccountManager.KEY_AUTHTOKEN); Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT); if (intent != null) { startActivityForResult(intent, 0); return; } Log.v(TAG, "onTokenAcquired: " + token); } catch (Exception e) { Log.v(TAG, "onTokenAcquired exception: " + e.toString()); } } }, new Handler() { }); } }
From source file:com.google.sampling.experiential.android.lib.GoogleAccountLoginHelper.java
private String getNewAuthToken(AccountManager accountManager, Account account) throws OperationCanceledException, IOException, AuthenticatorException { AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthToken(account, "ah", null, context, null, null);/* w w w . j av a 2 s . c o m*/ Bundle authTokenBundle = accountManagerFuture.getResult(); return authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString(); }
From source file:com.google.firebase.quickstart.fcm.MainActivity.java
private void logIntent(Intent intent, String title) { Log.d(TAG, String.format("%s: %s", title, intent)); if (intent.getExtras() != null) { Bundle extras = intent.getExtras(); String msg = ""; for (String key : extras.keySet()) { Object value = extras.get(key); if (msg.isEmpty()) { msg = String.format("Key: %s Value: %s", key, value); } else { msg = String.format("%s\nKey: %s Value: %s", msg, key, value); }//from www . j a v a2s . co m } Log.d(TAG, String.format("%s (extras):\n%s", title, msg)); } }