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.scoreflex.ScoreflexGcmClient.java

protected static PendingIntent buildPendingIntent(JSONObject scoreflexData, Context context,
        Class<? extends Activity> activity) {
    Intent resultIntent = new Intent(context, activity);

    resultIntent.putExtra(Scoreflex.NOTIFICATION_EXTRA_KEY, scoreflexData.toString());

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(activity);
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    return resultPendingIntent;
}

From source file:com.clevertrail.mobile.Database_SavedTrails.java

public static int openSavedTrails(Activity activity) {
    JSONArray jsonArray = null;//from  w  ww . ja  v  a 2 s.  c o m
    Database_SavedTrails db = new Database_SavedTrails(activity);
    db.openToRead();

    //getJSONString() without an argument returns all saved trails
    String jsonString = db.getJSONString();

    try {
        jsonArray = new JSONArray(jsonString);
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return R.string.error_corrupttrailindatabase;
    }

    db.close();

    //clear the traillist and then load it up with all the saved trails
    Object_TrailList.clearTrails();
    if (jsonArray != null && jsonArray.length() > 0) {
        int len = jsonArray.length();
        try {
            for (int i = 0; i < len && i < 20; ++i) {
                JSONObject trail = jsonArray.getJSONObject(i);
                //add trail information from the JSON
                Object_TrailList.addTrailWithJSON(trail);
            }
        } catch (JSONException e) {
            return R.string.error_corrupttrailindatabase;
        }
    }

    //prepare the extras for the saved trails activity (icon and title)
    int icon = R.drawable.ic_viewtrailtab_save_unselected;
    String title = "CleverTrail - Saved Trails";
    Intent i = new Intent(activity, Activity_ListTrails.class);
    i.putExtra("icon", icon);
    i.putExtra("title", title);
    activity.startActivity(i);

    return 0;
}

From source file:com.diona.videoplugin.CameraUtil.java

/**
 * Method to get the photo from the camera.
 * /*from w  w  w.j a  v  a  2 s . c  o  m*/
 * @param fragment
 *          fragment instance that holds the callback method for the camera utility
 */
public static void getPhotoFromCamera(final Fragment fragment) {
    final File imageFile = FileCacheUtil.getOutputMediaFile();
    if (imageFile != null && imageFile.exists()) {
        FileUtils.deleteQuietly(imageFile);
    }
    callingActivity = fragment;
    final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));

    // start the image capture Intent
    callingActivity.startActivityForResult(intent, CAMERA_REQUEST);
}

From source file:Main.java

public static void jumpToActivity(Context context, ComponentName componentName, String... datas) {
    Intent mIntent = new Intent();
    mIntent.addFlags(268435456);//from   w  w w  .  j av  a 2 s  . c  o  m
    mIntent.setComponent(componentName);
    mIntent.setAction("android.intent.action.VIEW");
    if (datas != null) {
        for (int i = 0; i < datas.length; ++i) {
            mIntent.putExtra("data" + i, datas[i]);
        }
    }

    context.startActivity(mIntent);
}

From source file:com.perm.DoomPlay.SearchVkActivity.java

public static Intent getVoiceIntent() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "voice search");
    return intent;
}

From source file:org.mozilla.gecko.tests.BaseRobocopTest.java

public static Intent createActivityIntent(Map<String, String> config) {
    final Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.putExtra("args", "-no-remote -profile " + config.get("profile"));
    // Don't show the first run experience.
    intent.putExtra(BrowserApp.EXTRA_SKIP_STARTPANE, true);

    final String envString = config.get("envvars");
    if (!TextUtils.isEmpty(envString)) {
        final String[] envStrings = envString.split(",");

        for (int iter = 0; iter < envStrings.length; iter++) {
            intent.putExtra("env" + iter, envStrings[iter]);
        }/*from w  w  w  .  j a  va2 s .  c  o  m*/
    }

    return intent;
}

From source file:ch.fixme.status.Widget.java

protected static Intent getIntent(Context ctxt, int widgetId) {
    Intent i = new Intent(ctxt, UpdateService.class);
    i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
    return i;//  w ww  .j a v  a 2 s . c  o  m
}

From source file:com.nagopy.android.xposed.utilities.ModBrightness.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@XMinSdkVersion(Build.VERSION_CODES.JELLY_BEAN_MR1)
@InitZygote(summary = "??")
public static void brightnessDebugger(final StartupParam startupParam, final ModBrightnessSettingsGen settings)
        throws Throwable {
    if (!settings.brightnessDebugger) {
        return;//from   w  ww. jav  a 2  s  .c  o  m
    }

    // DisplayPowerController??
    final Class<?> displayPowerContoroll = XposedHelpers
            .findClass("com.android.server.power.DisplayPowerController", null);

    // Context?
    XposedBridge.hookAllConstructors(displayPowerContoroll, new XC_MethodHook() {
        @Override
        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            Context context = (Context) param.args[1];
            XposedHelpers.setAdditionalInstanceField(param.thisObject, "mContext", context);

            XLog.d("mScreenAutoBrightnessSpline",
                    XposedHelpers.getObjectField(param.thisObject, "mScreenAutoBrightnessSpline"));
        }
    });

    XposedHelpers.findAndHookMethod(displayPowerContoroll, "updateAutoBrightness", boolean.class,
            new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    if (SystemClock.elapsedRealtime() < 60 * 1000) {
                        // ????
                        return;
                    }

                    Context mContext = (Context) XposedHelpers.getAdditionalInstanceField(param.thisObject,
                            "mContext");
                    Object mScreenAutoBrightness = XposedHelpers.getObjectField(param.thisObject,
                            "mScreenAutoBrightness");
                    Object mAmbientLux = XposedHelpers.getObjectField(param.thisObject, "mAmbientLux");
                    Intent intent = new Intent(AutoBrightnessController.ACTION_AUTO_BRIGHTNESS_CHANGED);
                    intent.putExtra(AutoBrightnessController.EXTRA_BRIGHTNESS, (Integer) mScreenAutoBrightness);
                    intent.putExtra(AutoBrightnessController.EXTRA_LUX, (Float) mAmbientLux);

                    // ????
                    UserHandle user = (UserHandle) XposedHelpers.getStaticObjectField(UserHandle.class, "ALL");
                    mContext.sendBroadcastAsUser(intent, user);
                }
            });
}

From source file:com.appnexus.opensdk.ANJAMImplementation.java

@SuppressLint("SetJavaScriptEnabled")
private static void callInternalBrowser(AdWebView webView, Uri uri) {
    String urlParam = uri.getQueryParameter("url");

    if ((webView.getContext() == null) || (urlParam == null) || (!urlParam.startsWith("http"))) {
        return;//from  w ww  . java 2 s  .c om
    }

    String url = Uri.decode(urlParam);
    Class<?> activity_clz = AdActivity.getActivityClass();

    Intent intent = new Intent(webView.getContext(), activity_clz);
    intent.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_BROWSER);

    WebView browserWebView = new WebView(webView.getContext());
    WebviewUtil.setWebViewSettings(browserWebView);
    BrowserAdActivity.BROWSER_QUEUE.add(browserWebView);
    browserWebView.loadUrl(url);

    if (webView.adView.getBrowserStyle() != null) {
        String i = "" + browserWebView.hashCode();
        intent.putExtra("bridgeid", i);
        AdView.BrowserStyle.bridge
                .add(new Pair<String, AdView.BrowserStyle>(i, webView.adView.getBrowserStyle()));
    }

    try {
        webView.getContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(webView.getContext(), R.string.action_cant_be_completed, Toast.LENGTH_SHORT).show();
        Clog.w(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName()));
        BrowserAdActivity.BROWSER_QUEUE.remove();
    }
}

From source file:com.nestapi.lib.UserAuthActivity.java

static void launchAuthFlowForResult(Activity activity, int requestCode, ClientMetadata data) {
    final Intent authFlowIntent = new Intent(activity, UserAuthActivity.class);
    authFlowIntent.putExtra(CLIENT_METADATA_KEY, data);
    log("Launching auth flow Activity...");
    activity.startActivityForResult(authFlowIntent, requestCode);
}