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:Main.java

public static boolean hasSpeechToText(Context context) {
    try {//w  w w.  j a  v a  2s. co  m
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, Locale.getDefault());
        return intent.resolveActivity(context.getPackageManager()) != null;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static void share(Context context, String imageFileLocation, String textToSend) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/*");

    intent.putExtra(Intent.EXTRA_TEXT, textToSend);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imageFileLocation)));

    context.startActivity(Intent.createChooser(intent, "Share with..."));
}

From source file:Main.java

public static void shareAppInfo(Context context, String info) {
    if (!TextUtils.isEmpty(info)) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, info);
        context.startActivity(intent);//from www . jav  a2  s  .c  o  m
    }
}

From source file:Main.java

public static void showSentEmailIntent(Context context, String subject, String body) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("message/rfc822");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, body);
    context.startActivity(emailIntent);/*from ww w  . j  a va  2s . c o m*/
}

From source file:Main.java

public static void requestHiddenServiceOnPort(Activity activity, int port) {
    Intent intent = new Intent(ACTION_REQUEST_HS);
    intent.setPackage(ORBOT_PACKAGE_NAME);
    intent.putExtra("hs_port", port);

    activity.startActivityForResult(intent, HS_REQUEST_CODE);
}

From source file:Main.java

public static void share(Context context, String textToSend) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");

    intent.putExtra(Intent.EXTRA_TEXT, textToSend);

    context.startActivity(Intent.createChooser(intent, "Share with..."));
}

From source file:Main.java

/**
 * Open Calendar app with specific time/*w w w  .j a v  a  2s  .  c  o  m*/
 */
public static void openCalendar(Activity activity, long epochEventStartTime) {
    Uri uri = Uri.parse("content://com.android.calendar/time/" + epochEventStartTime);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(uri);
    intent.putExtra("VIEW", "DAY");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    activity.startActivity(intent);
}

From source file:Main.java

public static void shareText(Context context, String title, String text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, title);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    context.startActivity(Intent.createChooser(intent, title));
}

From source file:Main.java

public static Intent getTweetIntent(Context context, String msg) {
    if (isTwitterClientInstalled(context)) {
        Intent intent = new Intent("com.twidroid.SendTweet");
        intent.putExtra("com.twidroid.extra.MESSAGE", msg);
        return intent;
    }//from  w w  w .j av a2 s  . c  o m
    return null;
}

From source file:Main.java

public static final void openGPS(Context context) {
    Intent intent = new Intent("com.nd.android.starapp.ui.jay.weibo.activity.GPS");
    intent.putExtra("enabled", true);
    context.sendBroadcast(intent);//from   ww w .  ja  v a2  s.  co m

    String provider = Settings.Secure.getString(context.getContentResolver(),
            Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
    if (!provider.contains("gps")) { //if gps is disabled
        final Intent poke = new Intent();
        poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
        poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
        poke.setData(Uri.parse("3"));
        context.sendBroadcast(poke);
    }
}