List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:android.support.v7.media.RemotePlaybackClient.java
private void performItemAction(final Intent intent, final String sessionId, final String itemId, Bundle extras, final ItemActionCallback callback) { intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); if (sessionId != null) { intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, sessionId); }/*from ww w .j a v a 2 s . com*/ if (itemId != null) { intent.putExtra(MediaControlIntent.EXTRA_ITEM_ID, itemId); } if (extras != null) { intent.putExtras(extras); } logRequest(intent); mRoute.sendControlRequest(intent, new MediaRouter.ControlRequestCallback() { @Override public void onResult(Bundle data) { if (data != null) { String sessionIdResult = inferMissingResult(sessionId, data.getString(MediaControlIntent.EXTRA_SESSION_ID)); MediaSessionStatus sessionStatus = MediaSessionStatus .fromBundle(data.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); String itemIdResult = inferMissingResult(itemId, data.getString(MediaControlIntent.EXTRA_ITEM_ID)); MediaItemStatus itemStatus = MediaItemStatus .fromBundle(data.getBundle(MediaControlIntent.EXTRA_ITEM_STATUS)); adoptSession(sessionIdResult); if (sessionIdResult != null && itemIdResult != null && itemStatus != null) { if (DEBUG) { Log.d(TAG, "Received result from " + intent.getAction() + ": data=" + bundleToString(data) + ", sessionId=" + sessionIdResult + ", sessionStatus=" + sessionStatus + ", itemId=" + itemIdResult + ", itemStatus=" + itemStatus); } callback.onResult(data, sessionIdResult, sessionStatus, itemIdResult, itemStatus); return; } } handleInvalidResult(intent, callback, data); } @Override public void onError(String error, Bundle data) { handleError(intent, callback, error, data); } }); }
From source file:jp.mixi.android.sdk.MixiContainerImpl.java
@Override public void requestPayment(final Activity activity, final PaymentParameter param, final int activityCode, final CallbackListener listener) { mPaymentCallbackListener = listener; mPaymentRequestCode = activityCode;/*from w w w . j a v a 2s . co m*/ if (!validatePaymentParam(param)) { listener.onError(new ErrorInfo("parameter invalid", ErrorInfo.OTHER_ERROR)); return; } Intent intent = new Intent(); intent.setClassName(OFFICIAL_PACKAGE, PAYMENT_ACTIVITY); intent.putExtras(convertPaymentBundle(param)); if (!validateOfficialAppsForIntent(activity, intent, VALIDATE_OFFICIAL_FOR_ACTIVITY, PAYMENT_SUPPORTED_VERSION)) { listener.onFatal(new ErrorInfo(activity.getString(R.string.err_unsupported_versions), ErrorInfo.OFFICIAL_APP_NOT_FOUND)); return; } try { activity.startActivityForResult(intent, activityCode); } catch (ActivityNotFoundException e) { Log.v(TAG, e.getMessage()); listener.onFatal(new ErrorInfo(e)); } }
From source file:ca.spencerelliott.mercury.Changesets.java
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); this.requestWindowFeature(Window.FEATURE_PROGRESS); this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.changesets); //Cancel any notifications previously setup NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(1);/* w w w. j a v a 2 s .c om*/ //Create a new array list for the changesets changesets_list = new ArrayList<Map<String, ?>>(); changesets_data = new ArrayList<Beans.ChangesetBean>(); //Get the list view to store the changesets changesets_listview = (ListView) findViewById(R.id.changesets_list); TextView empty_text = (TextView) findViewById(R.id.changesets_empty_text); //Set the empty view changesets_listview.setEmptyView(empty_text); //Use a simple adapter to display the changesets based on the array list made earlier changesets_listview.setAdapter(new SimpleAdapter(this, changesets_list, R.layout.changeset_item, new String[] { COMMIT, FORMATTED_INFO }, new int[] { R.id.changesets_commit, R.id.changesets_info })); //Set the on click listener changesets_listview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Intent intent = new Intent(Changesets.this, ChangesetViewer.class); //Pass the changeset information to the changeset viewer Bundle params = new Bundle(); params.putString("changeset_commit_text", changesets_data.get(position).getTitle()); params.putString("changeset_changes", changesets_data.get(position).getContent()); params.putLong("changeset_updated", changesets_data.get(position).getUpdated()); params.putString("changeset_authors", changesets_data.get(position).getAuthor()); params.putString("changeset_link", changesets_data.get(position).getLink()); //params.putBoolean("is_https", is_https); intent.putExtras(params); startActivity(intent); } }); //Register the list view for opening the context menu registerForContextMenu(changesets_listview); //Get the intent passed by the program if (getIntent() != null) { //Check to see if this is a search window if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) { //Change the title of the activity and the empty text of the list so it looks like a search window this.setTitle(R.string.search_results_label); empty_text.setText(R.string.search_results_empty); //Retrieve the query the user entered String query = getIntent().getStringExtra(SearchManager.QUERY); //Convert the query to lower case query = query.toLowerCase(); //Retrieve the bundle data Bundle retrieved_data = getIntent().getBundleExtra(SearchManager.APP_DATA); //If the bundle was passed, grab the changeset data if (retrieved_data != null) { changesets_data = retrieved_data .getParcelableArrayList("ca.spencerelliott.mercury.SEARCH_DATA"); } //If we're missing changeset data, stop here if (changesets_data == null) return; //Create a new array list to store the changesets that were a match ArrayList<Beans.ChangesetBean> search_beans = new ArrayList<Beans.ChangesetBean>(); //Loop through each changeset for (Beans.ChangesetBean b : changesets_data) { //Check to see if any changesets match if (b.getTitle().toLowerCase().contains(query)) { //Get the title and date of the commit String commit_text = b.getTitle(); Date commit_date = new Date(b.getUpdated()); //Add a new changeset to display in the list view changesets_list.add(createChangeset( (commit_text.length() > 30 ? commit_text.substring(0, 30) + "..." : commit_text), b.getRevisionID() + " - " + commit_date.toLocaleString())); //Add this bean to the list of found search beans search_beans.add(b); } } //Switch the changeset data over to the changeset data that was a match changesets_data = search_beans; //Update the list in the activity list_handler.sendEmptyMessage(SUCCESSFUL); //Notify the activity that it is a search window is_search_window = true; //Stop loading here return; } //Get the data from the intent Uri data = getIntent().getData(); if (data != null) { //Extract the path in the intent String path_string = data.getEncodedPath(); //Split it by the forward slashes String[] split_path = path_string.split("/"); //Make sure a valid path was passed if (split_path.length == 3) { //Get the repository id from the intent repo_id = Long.parseLong(split_path[2].toString()); } else { //Notify the user if there was a problem Toast.makeText(this, R.string.invalid_intent, 1000).show(); } } } //Retrieve the changesets refreshChangesets(); }
From source file:com.android.contacts.activities.PeopleActivity.java
@Override public void onClick(View view) { switch (view.getId()) { case R.id.floating_action_button: Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); Bundle extras = getIntent().getExtras(); if (extras != null) { intent.putExtras(extras); }/*from www .ja v a2 s . c om*/ try { ImplicitIntentsUtil.startActivityInApp(PeopleActivity.this, intent); } catch (ActivityNotFoundException ex) { Toast.makeText(PeopleActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show(); } break; default: Log.wtf(TAG, "Unexpected onClick event from " + view); } }
From source file:com.android.returncandidate.activities.SdmScannerActivity.java
/** * onRestart event handler/*from w ww . j av a2s. com*/ */ @Override protected void onRestart() { // Print log end process LogManager.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END); // Print log move screen LogManager.i(TAG, String.format(Message.MESSAGE_ACTIVITY_MOVE, Message.SCANNER_ACTIVITY_NAME, Message.UNLOCK_ACTIVITY_NAME)); super.onRestart(); if (timeout < (System.currentTimeMillis() - Constants.TIME_OUT)) { Intent intent = new Intent(this, UnlockScreenActivity.class); Bundle bundle = new Bundle(); HashMap<String, LinkedList<String[]>> hashMapArrBook = new HashMap<>(); hashMapArrBook.put(Constants.COLUMN_INFOR_LIST_SCAN, arrBookInlist); bundle.putString(Constants.COLUMN_USER_ID, userID); bundle.putString(Constants.COLUMN_SHOP_ID, shopID); bundle.putString(Constants.COLUMN_SERVER_NAME, serverName); bundle.putString(Constants.COLUMN_LICENSE, license); bundle.putSerializable(Constants.COLUMN_INFOR_LIST_SCAN, hashMapArrBook); intent.putExtras(bundle); startActivity(intent); finish(); Log.d("LINCONGPVUNCLOCK", license); } // Activate HSM license Log.d("LINCONGPVUNCLOCK1", license); ActivationResult activationResult = ActivationManager.activate(this, license); Toast.makeText(this, "Activation result: " + activationResult, Toast.LENGTH_LONG).show(); decCom = (HSMDecodeComponent) findViewById(R.id.hsm_decodeComponent); // HSM init hsmDecoder = HSMDecoder.getInstance(this); // Declare symbology if (aSwitchOCR.isChecked()) { flagSwitchOCR = Constants.FLAG_1; hsmDecoder.enableSymbology(Symbology.OCR); hsmDecoder.setOCRActiveTemplate(OCRActiveTemplate.ISBN); hsmDecoder.disableSymbology(Symbology.EAN13); } else { flagSwitchOCR = Constants.FLAG_0; hsmDecoder.enableSymbology(Symbology.EAN13); //hsmDecoder.setOCRActiveTemplate(OCRActiveTemplate.ISBN); hsmDecoder.disableSymbology(Symbology.OCR); } if (!isEnableScan) { hsmDecoder.disableSymbology(Symbology.EAN13); hsmDecoder.disableSymbology(Symbology.OCR); } //hsmDecoder.enableSymbology(Symbology.EAN13); // Declare HSM component UI hsmDecoder.enableFlashOnDecode(false); hsmDecoder.enableSound(false); hsmDecoder.enableAimer(false); hsmDecoder.setWindowMode(WindowMode.CENTERING); hsmDecoder.setWindow(18, 42, 0, 100); // Assign listener hsmDecoder.addResultListener(this); }
From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java
/** * open review mode to let user resolve conflict *//*from w w w .jav a 2s . co m*/ private void doManualMerge() { if (getActivity() instanceof TargetTranslationActivity) { ((TargetTranslationActivity) getActivity()).redrawTarget(); BackupDialog.this.dismiss(); // TODO: 4/20/16 it would be nice to navigate directly to the first conflict } else { // ask parent activity to navigate to a new activity Intent intent = new Intent(getActivity(), TargetTranslationActivity.class); Bundle args = new Bundle(); args.putString(App.EXTRA_TARGET_TRANSLATION_ID, targetTranslation.getId()); // TODO: 4/20/16 it would be nice to navigate directly to the first conflict // args.putString(App.EXTRA_CHAPTER_ID, chapterId); // args.putString(App.EXTRA_FRAME_ID, frameId); args.putInt(App.EXTRA_VIEW_MODE, TranslationViewMode.REVIEW.ordinal()); intent.putExtras(args); startActivity(intent); BackupDialog.this.dismiss(); } }
From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java
private void handleIntent(Intent intent) { // ? ? //from w w w. j ava2 s . c o m if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); // ? // doMixSearch(query); // } else if (intent.getExtras() != null) { FCMMessagingService.clear(intent.getStringExtra("traceID")); Intent traceIntent = new Intent(this, TraceActivity.class); traceIntent.putExtras(intent.getExtras()); topLayoutOnMixView.mainArView.setVisibility(View.GONE); startActivityForResult(traceIntent, SHOW_TRACE); } }
From source file:com.lewa.crazychapter11.MainActivity.java
public void clickHandler(View source) { // cal();//from w w w . j a v a2 s .c o m Bundle data = new Bundle(); data.putString("name", "algerhe"); // Intent intent = new Intent(MainActivity.this, OtherActivity.class); Intent intent = new Intent(MainActivity.this, SelectBookActivity.class); intent.putExtras(data); startActivity(intent); }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
private void retrieveLocation() { // Build HTTP request StringBuilder builder = new StringBuilder(); HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet( "http://maps.google." + "com/maps/api/geocode/json?address=" + addressURL + "&sensor=false"); // Send HTTP request try {//w w w. j ava 2 s. c o m HttpResponse response = client.execute(httpGet); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); if (statusCode == 200) { // Read the returned content into a string HttpEntity entity = response.getEntity(); InputStream content = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { builder.append(line); } } else { // Something is wrong, inform user of the error Log.e(TAG, "Failed to download file"); Toast.makeText(getApplicationContext(), "Location retrieval failed. Please try again", Toast.LENGTH_LONG).show(); Message msg = new Message(); msg.obj = "SHOW ADDRESS ENTER DIALOG"; handler.sendMessage(msg); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Create the JSONObject for parsing the string returned JSONObject jsonObject = new JSONObject(); try { jsonObject = new JSONObject(builder.toString()); } catch (JSONException e) { e.printStackTrace(); } // Parse the string returned into JSONObject try { addressArray = (JSONArray) jsonObject.get("results"); } catch (JSONException e) { e.printStackTrace(); } if (addressArray == null) { // Nothing returned, inform the user of the error Message msg = new Message(); msg.obj = "SHOW ADDRESS ENTER DIALOG - FAILED"; handler.sendMessage(msg); } else if (addressArray.length() == 0) { // No match found, inform the user of the error Message msg = new Message(); msg.obj = "SHOW ADDRESS ENTER DIALOG - NO RESULTS"; handler.sendMessage(msg); } else if (addressArray.length() == 1) { // Exact one result returned // Set the intent back to FindActivity Bundle bundle = new Bundle(); Intent newIntent = new Intent(); bundle.putString(Find.TIME, date); Double lng = new Double(0); Double lat = new Double(0); // Parse the JSONObject to get the longitude and latitude try { lng = addressArray.getJSONObject(0).getJSONObject("geometry").getJSONObject("location") .getDouble("lng"); lat = addressArray.getJSONObject(0).getJSONObject("geometry").getJSONObject("location") .getDouble("lat"); } catch (JSONException e) { e.printStackTrace(); } bundle.putDouble(Find.LONGITUDE, lng); bundle.putDouble(Find.LATITUDE, lat); bundle.putInt(Find.IS_ADHOC, REMINDER_SET); newIntent.putExtras(bundle); setResult(RESULT_OK, newIntent); finish(); } else { // More than one results returned // Show Address Confirm Dialog for user confirmation Message msg = new Message(); msg.obj = "SHOW ADDRESS CONFIRM DIALOG"; handler.sendMessage(msg); } }
From source file:com.arya.portfolio.view_controller.fragment.UseCasesFragment.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Intent intent; Bundle bundle = new Bundle(); if (txtProductEngineering.isSelected()) { intent = new Intent(getActivity(), PortfolioSingleActivity.class); bundle.putSerializable("listData", listData); bundle.putInt("position", i); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_CODE); } else if (txtIndustry.isSelected()) { /* intent = new Intent(getActivity(), IndustrySingleActivity.class); bundle.putSerializable("listIndData", listIndData); bundle.putInt("position", i);//from w w w . j a v a 2 s . c o m intent.putExtras(bundle); startActivityForResult(intent, REQUEST_CODE);*/ intent = new Intent(getActivity(), PortfolioList.class); String industryCategory = listIndData.get(i).categoryName.trim(); ArrayList<PortfolioData> portfolioListIndustry = DBManagerAP.getInstance().getProductAccToCategory("", "", industryCategory); bundle.putSerializable("listData", portfolioListIndustry); bundle.putString("title", industryCategory); bundle.putInt("position", i); intent.putExtras(bundle); startActivity(intent); } else { intent = new Intent(getActivity(), PortfolioList.class); String technologyName = listTechData.get(i).technologyName.toLowerCase().trim(); ArrayList<PortfolioData> portfolioList = DBManagerAP.getInstance().getProductAccToCategory("", technologyName, ""); bundle.putSerializable("listData", portfolioList); bundle.putString("title", listTechData.get(i).technologyName); bundle.putInt("position", i); intent.putExtras(bundle); startActivity(intent); } }