List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:Main.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") public static void toggleAirplane(Context context) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) return;/* w w w . j a va 2s . c om*/ int state = 0; try { if (isJBean()) state = Settings.System.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON); else state = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON); } catch (SettingNotFoundException e) { e.printStackTrace(); } if (state == 0) { if (isJBean()) Settings.System.putInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1); else Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", true); context.sendBroadcast(intent); } else { if (isJBean()) Settings.System.putInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0); else Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", false); context.sendBroadcast(intent); } }
From source file:Main.java
private static void setBadgeSony(Context context, int count) { String launcherClassName = getLauncherClassName(context); if (launcherClassName == null) { return;/* w ww . j a v a 2s .co m*/ } Intent intent = new Intent(); intent.setAction("com.sonyericsson.home.action.UPDATE_BADGE"); intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", launcherClassName); intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true); intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", String.valueOf(count)); intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", context.getPackageName()); context.sendBroadcast(intent); }
From source file:Main.java
/** * Lancia la finestra per la selezione di un gestore per la condivisione di un messaggio * (twitter, facebook, ....).//from w w w . j a va2 s . c om * * @param context * @param dialogTitle - Titolo della finestra di dialog (Share...) * @param subject - Subject (della email o titolo di twitter) * @param text - Testo del messaggio */ public static void share(Context context, String dialogTitle, String subject, String text) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(intent, dialogTitle)); }
From source file:Main.java
public static void shareToGMail(Context context, String[] email, String subject, String content) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(Intent.EXTRA_EMAIL, email); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content); final PackageManager pm = context.getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0); ResolveInfo best = null;//from w ww . j a v a2s. c om for (final ResolveInfo info : matches) if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) best = info; if (best != null) emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name); context.startActivity(emailIntent); }
From source file:Main.java
public static Intent getEmailIntent(String toEmailAdr, String subject, String message, File attachmentFile, String intentChooserTitle) { String uriText = "mailto:" + toEmailAdr + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(message);//from w ww . j a v a 2 s.c om Uri uri = Uri.parse(uriText); Intent sendIntent = new Intent(Intent.ACTION_SENDTO); sendIntent.setData(uri); if (attachmentFile != null) sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(attachmentFile)); return Intent.createChooser(sendIntent, intentChooserTitle); }
From source file:Main.java
public static void mail(Activity activity, String subject, String text, String mail) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:" + mail)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); activity.startActivity(intent);/*from www . j a v a2s .co m*/ }
From source file:Main.java
public static void sendText(Context context, String text) { String mimeType = getMimeTypeForExtension("txt"); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType(mimeType);/* w w w . j a v a2s . c om*/ intent.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(intent); }
From source file:Main.java
public static void cropImgFromSelfCenter(Uri uri) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 110); intent.putExtra("aspectY", 135); intent.putExtra("outputX", 110); intent.putExtra("outputY", 135); intent.putExtra("return-data", false); intent.putExtra("noFaceDetection", true); File mFile = new File(Environment.getExternalStorageDirectory() + "/yourName"); if (!mFile.exists()) mFile.mkdirs();/*w w w. j a v a2 s .c o m*/ mCropAvatar = new File(CROP_IMG_PATH); if (mCropAvatar.exists()) mCropAvatar.delete(); mCropUri = Uri.fromFile(mCropAvatar); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCropUri); mActivity.startActivityForResult(intent, REQUEST_CROP_RETURN_SELF_CENTER); }
From source file:Main.java
public static void shareFile(Context context, String title, String filePath) { Intent intent = new Intent(Intent.ACTION_SEND); Uri uri = Uri.parse("file://" + filePath); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_STREAM, uri); context.startActivity(Intent.createChooser(intent, title)); }
From source file:com.example.awesomedogs.ui.DogDetailActivity.java
static void startActivity(Context context, String id) { Intent intent = new Intent(context, DogDetailActivity.class); intent.putExtra(EXTRA_DOG_ID, id); context.startActivity(intent);//from w w w. j av a2 s. com }