List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:Main.java
public static void installApk(Context context, Uri file) { if (context == null) return;//from w w w. jav a2 s. c o m if (file == null) return; Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(file, "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
public static void shareViaSms(Context context, String subject, String text) { Intent intent = new Intent(); intent.setType("text/plain"); intent.setData(Uri.parse("sms:")); intent.setAction(Intent.ACTION_VIEW); intent.putExtra("sms_body", text); context.startActivity(Intent.createChooser(intent, "Share via SMS")); }
From source file:Main.java
public static Intent getSelectSystemImageIntent() { Intent intent = null; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); }// ww w. j a va 2s . co m // else { // intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); // intent.addCategory(Intent.CATEGORY_OPENABLE); // } return intent; }
From source file:Main.java
public static void installApk(Context context, String filePath) { Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(filePath)), "application/vnd.android.package-archive"); context.startActivity(intent);//w ww .j a v a 2 s . co m }
From source file:Main.java
public static void showUCBrowser(Context context, String visitUrl) { Intent intent = new Intent(); intent.setClassName("com.uc.browser", "com.uc.browser.ActivityUpdate"); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse(visitUrl)); context.startActivity(intent);/* www . j av a 2 s . c o m*/ }
From source file:Main.java
public static void showQQBrowser(Context context, String visitUrl) { Intent intent = new Intent(); intent.setClassName("com.tencent.mtt", "com.tencent.mtt.MainActivity"); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse(visitUrl)); context.startActivity(intent);/* w w w. j av a2 s . co m*/ }
From source file:Main.java
public static Intent pickImage(int PICK_IMAGE) { Intent intent = new Intent(); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.setAction(Intent.ACTION_GET_CONTENT); return Intent.createChooser(intent, "Select Picture"); }
From source file:Main.java
public static void showOperaBrowser(Context context, String visitUrl) { Intent intent = new Intent(); intent.setClassName("com.opera.mini.android", "com.opera.mini.android.Browser"); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse(visitUrl)); context.startActivity(intent);//from w w w .ja v a 2 s .co m }
From source file:Main.java
public static void openMailChooser(Context context, String text, String[] mails, String subject) { Intent mailIntent = new Intent(); mailIntent.setAction(Intent.ACTION_SEND); mailIntent.putExtra(Intent.EXTRA_TEXT, text); mailIntent.putExtra(Intent.EXTRA_EMAIL, mails); mailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); mailIntent.setType(INTENT_TYPE_MSG); PackageManager pm = context.getPackageManager(); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(INTENT_TYPE_TEXT); Intent openInChooser = Intent.createChooser(mailIntent, ""); List<ResolveInfo> resInfo = pm.queryIntentActivities(sendIntent, 0); List<LabeledIntent> intentList = new ArrayList<LabeledIntent>(); for (ResolveInfo ri : resInfo) { String packageName = ri.activityInfo.packageName; if (packageName.contains(PACKAGE_EMAIL)) { mailIntent.setPackage(packageName); } else if (packageName.contains(PACKAGE_MMS) || packageName.contains(PACKAGE_GMAIL)) { Intent intent = new Intent(); intent.setComponent(new ComponentName(packageName, ri.activityInfo.name)); intent.setAction(Intent.ACTION_SEND); intent.setType(INTENT_TYPE_TEXT); if (packageName.contains(PACKAGE_MMS)) { intent.putExtra("subject", subject); intent.putExtra("sms_body", text); intent.putExtra("address", mails[0]); intent.setType(INTENT_TYPE_MSG); } else if (packageName.contains(PACKAGE_GMAIL)) { intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_EMAIL, mails); intent.setType(INTENT_TYPE_MSG); }/*from w ww . j av a 2s . co m*/ intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm), ri.icon)); } } LabeledIntent[] extraIntents = intentList.toArray(new LabeledIntent[intentList.size()]); openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); context.startActivity(openInChooser); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, String value) { Intent intent = new Intent(); intent.putExtra(name, value);//from w ww . ja v a 2s .c o m intent.setAction(filter); context.sendBroadcast(intent); }