List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:Main.java
public static void shareOnFacebook(Context pContext, String urlToShare) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // intent.putExtra(Intent.EXTRA_SUBJECT, "Foo bar"); // NB: has no effect! intent.putExtra(Intent.EXTRA_TEXT, urlToShare); // See if official Facebook app is found boolean facebookAppFound = false; List<ResolveInfo> matches = pContext.getPackageManager().queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo.packageName.toLowerCase().startsWith("com.facebook.katana")) { intent.setPackage(info.activityInfo.packageName); facebookAppFound = true;/*from w ww . j a va2 s .c o m*/ break; } } // As fallback, launch sharer.php in a browser if (!facebookAppFound) { String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare; intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl)); } pContext.startActivity(intent); }
From source file:com.hybris.mobile.app.commerce.helper.ProductHelper.java
/** * Redirect to the product details page// w ww .j av a 2s . c o m * * @param context * @param productCode */ public static void redirectToProductDetail(Context context, String productCode) { if (StringUtils.isNotBlank(productCode)) { Intent intentProductDetail = new Intent(context, ProductDetailActivity.class); intentProductDetail.putExtra(IntentConstants.PRODUCT_CODE, productCode); context.startActivity(intentProductDetail); } }
From source file:Main.java
protected static void launchFallbackSupportUri(Context context) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(FALLBACK_SUPPORT_URL)); // Let Chrome know that this intent is from Chrome, so that it does not close the app when // the user presses 'back' button. intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); intent.setPackage(context.getPackageName()); context.startActivity(intent);/* www . j a va2s.co m*/ }
From source file:com.applift.api.tester.activity.RenderedResponseActivity.java
public static Intent getIntent(Context ctx, AdFormat format, JSONObject obj) { Intent intent = new Intent(ctx, RenderedResponseActivity.class); intent.putExtra(FORMAT, format); fillIntent(intent, obj);//from www. j a v a 2 s .c om return intent; }
From source file:com.manning.androidhacks.hack036.util.LaunchEmailUtil.java
public static void launchEmailToIntent(Context context) { Intent msg = new Intent(Intent.ACTION_SEND); StringBuilder body = new StringBuilder("\n\n----------\n"); body.append(EnvironmentInfoUtil.getApplicationInfo(context)); msg.putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.mail_support_feedback_to).split(", ")); msg.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.mail_support_feedback_subject)); msg.putExtra(Intent.EXTRA_TEXT, body.toString()); msg.setType("message/rfc822"); context.startActivity(Intent.createChooser(msg, context.getString(R.string.pref_sendemail_title))); }
From source file:Main.java
/** * Share App// ww w . ja v a 2s .c om * * @param context */ public static void shareApp(Context context) { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); String title = "Share NavigationFastFrame"; String extraText = "NavigationFastFrame is a very good Frame."; intent.putExtra(Intent.EXTRA_TEXT, extraText); //Share text. intent.putExtra(Intent.EXTRA_SUBJECT, title); context.startActivity(Intent.createChooser(intent, "Share this")); }
From source file:sg.macbuntu.android.pushcontacts.DeviceRegistrar.java
private static String getAuthToken(Context context, Account account) { String authToken = null;/*from w w w. j a va 2 s . com*/ AccountManager accountManager = AccountManager.get(context); try { AccountManagerFuture<Bundle> future = accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, 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 auth token - will need to ask permission from user. Intent intent = new Intent(ActivityUI.AUTH_PERMISSION_ACTION); intent.putExtra("AccountManagerBundle", bundle); context.sendBroadcast(intent); } } catch (OperationCanceledException e) { Log.w(TAG, e.getMessage()); } catch (AuthenticatorException e) { Log.w(TAG, e.getMessage()); } catch (IOException e) { Log.w(TAG, e.getMessage()); } return authToken; }
From source file:com.dalthed.tucan.TucanMobile.java
public static void alertOnTucanDown(final Context context, String error) { Dialog tucanDownDialog = new AlertDialog.Builder(context).setTitle("").setMessage(error) .setPositiveButton("Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent goToLogin = new Intent(context, TuCanMobileActivity.class); goToLogin.putExtra("loggedout", true); context.startActivity(goToLogin); }/*from ww w . j a v a 2 s.co m*/ }).create(); }
From source file:Main.java
public static List<Intent> createTakePictureIntentList(@NonNull Context context, @NonNull Uri outputFileUri) { List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { String packageName = res.activityInfo.packageName; Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName);/*from www. ja va 2s . co m*/ intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(intent); } return cameraIntents; }
From source file:Main.java
static Intent createOpenCalendarAtDayIntent(Context context, DateTime goToTime) { Intent launchIntent = createCalendarIntent(Intent.ACTION_VIEW); Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath(TIME);/*w w w . j av a2 s . c om*/ if (goToTime.getMillis() != 0) { launchIntent.putExtra(KEY_DETAIL_VIEW, true); ContentUris.appendId(builder, goToTime.getMillis()); } launchIntent.setData(builder.build()); return launchIntent; }