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:com.google.android.apps.chrometophone.DeviceRegistrar.java

public static void registerWithServer(final Context context, final String deviceRegistrationID) {
    new Thread(new Runnable() {
        @Override/*  ww w .j  a v a  2  s  .  com*/
        public void run() {
            Intent updateUIIntent = new Intent("com.google.ctp.UPDATE_UI");
            try {
                HttpResponse res = makeRequest(context, deviceRegistrationID, REGISTER_PATH);
                if (res.getStatusLine().getStatusCode() == 200) {
                    GCMRegistrar.setRegisteredOnServer(context, true);
                    updateUIIntent.putExtra(STATUS_EXTRA, REGISTERED_STATUS);
                } else if (res.getStatusLine().getStatusCode() == 400) {
                    updateUIIntent.putExtra(STATUS_EXTRA, AUTH_ERROR_STATUS);
                } else {
                    Log.w(TAG, "Registration error " + String.valueOf(res.getStatusLine().getStatusCode()));
                    updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                }
                context.sendBroadcast(updateUIIntent);
                // Check if this is an update from C2DM to GCM - if it is, remove the
                // old registration id.
                SharedPreferences settings = Prefs.get(context);
                String c2dmRegId = settings.getString("deviceRegistrationID", null);
                if (c2dmRegId != null) {
                    Log.i(TAG, "Removing old C2DM registration id");
                    SharedPreferences.Editor editor = settings.edit();
                    editor.remove("deviceRegistrationID");
                    editor.commit();
                }
            } catch (AppEngineClient.PendingAuthException pae) {
                // Get setup activity to ask permission from user.
                Intent intent = new Intent(SetupActivity.AUTH_PERMISSION_ACTION);
                intent.putExtra("AccountManagerBundle", pae.getAccountManagerBundle());
                context.sendBroadcast(intent);
            } catch (Exception e) {
                Log.w(TAG, "Registration error " + e.getMessage());
                updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                context.sendBroadcast(updateUIIntent);
            }
        }
    }).start();
}

From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java

public static void shareImage(Fragment fragment, JSONParcelable imageData) {
    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    try {//from   w  ww  . ja  va  2  s  . com
        intent.putExtra(Intent.EXTRA_TEXT,
                imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK));
    } catch (JSONException e) {
        Log.e("Error!", "bad link to share");
    }
    fragment.startActivity(intent);
}

From source file:com.eyekabob.util.EyekabobHelper.java

public static void launchEmail(Activity activity) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("plain/text");
    String to[] = { "philj21@yahoo.com", "adam.sill01@gmail.com", "coffbr01@gmail.com" };
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Eyekabob Advertising");
    String label = activity.getResources().getString(R.string.write_email);
    activity.startActivity(Intent.createChooser(emailIntent, label));
}

From source file:com.phonemetra.account.util.AccountUtils.java

private static Intent getWifiSetupIntent(Context context) {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(new ComponentName(Account.WIFI_COMPONENT_PKG, Account.WIFI_COMPONENT_CLASS));
    intent.putExtra(Account.EXTRA_FIRST_RUN, true);
    intent.putExtra(Account.EXTRA_ALLOW_SKIP, false);
    intent.putExtra(Account.EXTRA_SHOW_BUTTON_BAR, true);
    intent.putExtra(Account.EXTRA_ONLY_ACCESS_POINTS, true);
    intent.putExtra(Account.EXTRA_AUTO_FINISH, true);
    return intent;
}

From source file:com.github.chenxiaolong.dualbootpatcher.FileUtils.java

private static void setCommonSaveOptions(Intent intent, String mimeType, String defaultName) {
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(mimeType);/* w  ww. j  a va 2s .  com*/
    intent.putExtra(Intent.EXTRA_TITLE, defaultName);
}

From source file:com.userhook.UserHook.java

public static void showSurvey(String surveyId, String surveyTitle, UHHookPoint hookPoint) {

    Intent intent = new Intent(activityLifecycle.getCurrentActivity(), UHHostedPageActivity.class);

    intent.putExtra(UHHostedPageActivity.TYPE_SURVEY, surveyId);
    intent.putExtra(UHHostedPageActivity.SURVEY_TITLE, surveyTitle);
    if (hookPoint != null) {
        intent.putExtra(UHHostedPageActivity.HOOKPOINT_ID, hookPoint.getId());
    }/*w  w  w  .  j  a v a  2 s.  c  om*/

    activityLifecycle.getCurrentActivity().startActivity(intent);
}

From source file:com.userhook.UserHook.java

public static void showFeedback() {

    Intent intent = new Intent(activityLifecycle.getCurrentActivity(), UHHostedPageActivity.class);
    intent.putExtra(UHHostedPageActivity.TYPE_FEEDBACK, feedbackScreenTitle);

    if (feedbackCustomFields != null && feedbackCustomFields.size() > 0) {
        Bundle bundle = new Bundle();
        for (String key : feedbackCustomFields.keySet()) {
            bundle.putString(key, feedbackCustomFields.get(key));
        }/*from   ww w  .  j a  va2  s.c  o m*/
        intent.putExtra(UH_CUSTOM_FIELDS, bundle);
    }

    activityLifecycle.getCurrentActivity().startActivity(intent);
}

From source file:Main.java

public static Intent share(String text, String mimeType, Uri... attachments) {
    final Intent intent = new Intent();
    intent.setType(mimeType);//from   w ww . j  a v a 2s  . c om
    if (attachments.length > 1) {
        intent.setAction(Intent.ACTION_SEND_MULTIPLE);
        final ArrayList<CharSequence> textExtra = new ArrayList<>();
        textExtra.add(text);
        intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra);
        final ArrayList<Parcelable> uris = new ArrayList<>();
        Collections.addAll(uris, attachments);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    } else {
        intent.setAction(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_TEXT, text);
        intent.putExtra(Intent.EXTRA_STREAM, attachments[0]);
    }
    return intent;
}