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:im.delight.android.commons.Social.java

/**
 * Displays an application chooser and shares the specified file using the selected application
 *
 * @param context a context reference/*from   w w w  . j  av  a 2 s. c om*/
 * @param windowTitle the title for the application chooser's window
 * @param fileToShare the file to be shared
 * @param mimeTypeForFile the MIME type for the file to be shared (e.g. `image/jpeg`)
 * @param subjectTextToShare the message title or subject for the file, if supported by the target application
 */
public static void shareFile(final Context context, final String windowTitle, final File fileToShare,
        final String mimeTypeForFile, final String subjectTextToShare) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType(mimeTypeForFile);
    intent.putExtra(Intent.EXTRA_SUBJECT, subjectTextToShare);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileToShare));
    context.startActivity(Intent.createChooser(intent, windowTitle));
}

From source file:de.evilbrain.sendtosftp.config.java

public static void putSettingsToIntent(Intent intent, JSONObject jsonSettings) {
    intent.putExtra("jsonSettings", jsonSettings.toString());
}

From source file:edu.stanford.junction.android.AndroidJunctionMaker.java

/**
 * Returns an Intent than can be used to join a Junction activity.
 * If you want a specific class to handle this intent,
 * you can specify the package/class on the returned
 * Intent before using it to start an activity.
 * //from w  w w  .  j av a  2 s.  c  om
 * @param junctionInvitation
 * @return
 */
public static Intent getIntentForActivityJoin(URI junctionInvitation) {
    Intent launchIntent = new Intent(Intents.ACTION_JOIN);
    launchIntent.putExtra("junctionVersion", 1);
    //launchIntent.putExtra("activityDescriptor", invitation.toString());
    // TODO: keep URI?
    launchIntent.putExtra(Intents.EXTRA_ACTIVITY_SESSION_URI, junctionInvitation.toString());

    return launchIntent;
}

From source file:Main.java

public static void delShortcutFromDesktop(Context paramContext, String packageName, String cls,
        String appName) {// ww  w .j  a va 2 s  . com
    Intent localIntent1 = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
    String str = appName;
    PackageManager localPackageManager = paramContext.getPackageManager();
    int i = 8320;
    try {
        ApplicationInfo localApplicationInfo = localPackageManager.getApplicationInfo(packageName, i);
        if (str == null)
            str = localPackageManager.getApplicationLabel(localApplicationInfo).toString();
        localIntent1.putExtra("android.intent.extra.shortcut.NAME", str);
        ComponentName localComponentName = new ComponentName(packageName, cls);
        Intent localIntent2 = new Intent(Intent.ACTION_MAIN).setComponent(localComponentName);
        localIntent2.addCategory(Intent.CATEGORY_LAUNCHER);
        localIntent1.putExtra("android.intent.extra.shortcut.INTENT", localIntent2);
        paramContext.sendBroadcast(localIntent1);
        return;
    } catch (PackageManager.NameNotFoundException localNameNotFoundException) {
        while (true)
            localNameNotFoundException.printStackTrace();
    }
}

From source file:net.reichholf.dreamdroid.intents.IntentFactory.java

public static Intent getStreamFileIntent(String fileName, String title) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    SimpleHttpClient shc = SimpleHttpClient.getInstance();
    ArrayList<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair("file", fileName));
    Uri uri = Uri.parse(shc.buildFileStreamUrl(URIStore.FILE, params));
    Log.i(DreamDroid.LOG_TAG, "Streaming file: " + uri.getEncodedQuery());

    intent.setDataAndType(uri, "video/*");
    intent.putExtra("title", title);
    return intent;
}

From source file:com.facebook.unity.FB.java

@UnityCallable
public static void LoginWithReadPermissions(String params_str) {
    Log.v(TAG, "LoginWithReadPermissions(" + params_str + ")");
    Intent intent = new Intent(getUnityActivity(), FBUnityLoginActivity.class);
    intent.putExtra(FBUnityLoginActivity.LOGIN_PARAMS, params_str);
    intent.putExtra(FBUnityLoginActivity.LOGIN_TYPE, FBUnityLoginActivity.LoginType.READ);
    getUnityActivity().startActivity(intent);
}

From source file:com.facebook.unity.FB.java

@UnityCallable
public static void LoginWithPublishPermissions(String params_str) {
    Log.v(TAG, "LoginWithPublishPermissions(" + params_str + ")");
    Intent intent = new Intent(getUnityActivity(), FBUnityLoginActivity.class);
    intent.putExtra(FBUnityLoginActivity.LOGIN_PARAMS, params_str);
    intent.putExtra(FBUnityLoginActivity.LOGIN_TYPE, FBUnityLoginActivity.LoginType.PUBLISH);
    getUnityActivity().startActivity(intent);
}

From source file:com.facebook.unity.FB.java

@UnityCallable
public static void loginForTVWithReadPermissions(String params_str) {
    Log.v(TAG, "loginForTVWithReadPermissions(" + params_str + ")");
    Intent intent = new Intent(getUnityActivity(), FBUnityLoginActivity.class);
    intent.putExtra(FBUnityLoginActivity.LOGIN_PARAMS, params_str);
    intent.putExtra(FBUnityLoginActivity.LOGIN_TYPE, FBUnityLoginActivity.LoginType.TV_READ);
    getUnityActivity().startActivity(intent);
}

From source file:com.facebook.unity.FB.java

@UnityCallable
public static void LoginForTVWithPublishPermissions(String params_str) {
    Log.v(TAG, "LoginForTVWithPublishPermissions(" + params_str + ")");
    Intent intent = new Intent(getUnityActivity(), FBUnityLoginActivity.class);
    intent.putExtra(FBUnityLoginActivity.LOGIN_PARAMS, params_str);
    intent.putExtra(FBUnityLoginActivity.LOGIN_TYPE, FBUnityLoginActivity.LoginType.TV_PUBLISH);
    getUnityActivity().startActivity(intent);
}

From source file:com.google.android.gcm.GCMRegistrar.java

static void internalUnregister(Context context) {
    Log.v(TAG, "Unregistering app " + context.getPackageName());
    Intent intent = new Intent(GCMConstants.INTENT_TO_GCM_UNREGISTRATION);
    intent.setPackage(GSF_PACKAGE);//from   ww  w  .  j  ava 2s  . co m
    intent.putExtra(GCMConstants.EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    context.startService(intent);
}