Example usage for android.content Intent putExtra

List of usage examples for android.content Intent putExtra

Introduction

In this page you can find the example usage for android.content Intent putExtra.

Prototype

@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value) 

Source Link

Document

Add extended data to the intent.

Usage

From source file:cc.softwarefactory.lokki.android.services.DataService.java

public static void getPlaces(Context context) {

    Log.e(TAG, "getPlaces");
    Intent placesIntent = new Intent(context, DataService.class);
    placesIntent.putExtra(GET_PLACES, 1);
    context.startService(placesIntent);/*  ww  w  .jav  a 2 s.  co m*/
}

From source file:cc.softwarefactory.lokki.android.services.DataService.java

public static void getDashboard(Context context) {

    Log.e(TAG, "getDashboard");
    Intent placesIntent = new Intent(context, DataService.class);
    placesIntent.putExtra(ALARM_TIMER, 1);
    context.startService(placesIntent);/*w ww.  j av  a 2  s. c  o  m*/
}

From source file:Main.java

/**
 * Intent chooser is customized to remove unwanted apps.
 * 1. FaceBook has bug where only links can be shared.
 * 2. Cannot share this type of content via Google Docs and Skype.
 *///from w  w  w  .  ja  v  a  2  s  .  c o m
public static void ShareResult(Context mContext, String mResult, String mTitle) {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    List<ResolveInfo> resInfo = mContext.getPackageManager().queryIntentActivities(shareIntent, 0);
    if (!resInfo.isEmpty()) {
        for (ResolveInfo resolveInfo : resInfo) {
            String packageName = resolveInfo.activityInfo.packageName;
            Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
            targetedShareIntent.setType("text/plain");
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TITLE, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mResult);
            if (!packageName.toLowerCase().contains("com.facebook.katana")
                    && !packageName.toLowerCase().contains("com.google.android.apps.docs")
                    && !packageName.toLowerCase().contains("com.skype.raider")) {
                targetedShareIntent.setPackage(packageName);
                targetedShareIntents.add(targetedShareIntent);
            }
        }
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Send your result");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {}));
        mContext.startActivity(chooserIntent);
    }
    return;
}

From source file:com.app.common.util.IntentUtils.java

public static void start_activity(Activity activity, Class<?> cls, BasicNameValuePair... name) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);//from   ww  w  .  ja  va2s .  c  om
    for (int i = 0; i < name.length; i++) {
        intent.putExtra(name[i].getName(), name[i].getValue());
    }
    activity.startActivity(intent);
}

From source file:com.mercandalli.android.apps.files.file.text.FileTextActivity.java

public static void start(@NonNull final Activity activity, final FileModel fileModel, final boolean isOnline) {
    final Intent intent = new Intent(activity, FileTextActivity.class);
    intent.putExtra(EXTRA_MODEL_FILE_URL, "" + fileModel.getOnlineUrl());

    if (FileTypeModelENUM.FILESPACE.type.equals(fileModel.getType())) {
        intent.putExtra(EXTRA_MODEL_FILE_ARTICLE_CONTENT_1,
                "" + fileModel.getContent().getArticle().article_content_1);
    }/*w  ww. j  ava 2  s.c  om*/

    intent.putExtra(EXTRA_MODEL_FILE_ONLINE, isOnline);
    activity.startActivity(intent);
    activity.overridePendingTransition(R.anim.left_in, R.anim.left_out);
}

From source file:Main.java

/**
 * Helper method for sharing an image.//from w  w w .j  a v a 2  s  . co  m
 *
 * @param context   The image context.
 * @param imagePath The path of the image to be shared.
 */
static void shareImage(Context context, String imagePath) {
    // Create the share intent and start the share activity
    File imageFile = new File(imagePath);
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri photoURI = FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY, imageFile);
    shareIntent.putExtra(Intent.EXTRA_STREAM, photoURI);
    context.startActivity(shareIntent);
}

From source file:com.google.android.gcm.demo.app.GCMIntentService.java

/**
 * Issues a notification to inform the user that server has sent a message.
 *//*from w  w w .j a v a  2  s .c o  m*/
private static void generateNotification(Context context, String message, String data) {
    int icon = R.drawable.ic_stat_gcm;
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(0);

    Notification notification = new Notification(icon, message, when);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, DemoActivity.class);
    notificationIntent.putExtra(CommonUtilities.EXTRA_TEAM_IN_JSON, data);
    // set intent so it does not start a new activity
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags = Notification.FLAG_AUTO_CANCEL;
    notificationManager.notify(0, notification);
}

From source file:Main.java

public static void goToMiuiPermissionActivity_V7(Context context) {
    Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
    intent.setClassName("com.miui.securitycenter",
            "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
    intent.putExtra("extra_pkgname", context.getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (isIntentAvailable(intent, context)) {
        context.startActivity(intent);/*from   www  .j ava 2 s  .co  m*/
    } else {
        Log.e(TAG, "Intent is not available!");
    }
}

From source file:Main.java

public static void goToMiuiPermissionActivity_V6(Context context) {
    Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
    intent.setClassName("com.miui.securitycenter",
            "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
    intent.putExtra("extra_pkgname", context.getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (isIntentAvailable(intent, context)) {
        context.startActivity(intent);/*from  w w w  .  j av  a 2  s . c  o  m*/
    } else {
        Log.e(TAG, "Intent is not available!");
    }
}

From source file:Main.java

private static void shareImageOnFacebook(String imagePath, Context context) {

    Log.d("CitationsManager-ShareOnFb", "sharing the image " + imagePath);
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    // shareIntent.putExtra(Intent.EXTRA_TEXT, "www.google.com");
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
    for (final ResolveInfo app : activityList) {

        Log.d("CitationsManager-ShareOnFb", app.activityInfo.name);
        if ((app.activityInfo.name).contains("com.facebook") && !(app.activityInfo.name).contains("messenger")
                && !(app.activityInfo.name).contains("pages")) {
            final ActivityInfo activity = app.activityInfo;
            final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
            shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            shareIntent.setComponent(name);
            context.startActivity(shareIntent);
            break;
        }//from w w w . j  a va  2 s . c o m
    }

}