List of usage examples for android.content Intent setComponent
public @NonNull Intent setComponent(@Nullable ComponentName component)
From source file:Main.java
public static void startComponent(Context context, String packageName, String className) { Intent intent = new Intent(); ComponentName component = new ComponentName(packageName, className); intent.setComponent(component); if (intent != null) { context.startActivity(intent);/*from ww w . j ava 2 s. com*/ } }
From source file:Main.java
public static void openSettings(Activity context, String action) { Intent intent = new Intent(); ComponentName comp = new ComponentName("com.android.settings", action); intent.setComponent(comp); intent.setAction("android.intent.action.VIEW"); context.startActivityForResult(intent, 0); }
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 ww w . java2s.c o 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 startMobileDataSettingActivity(Context context) { Intent mIntent = new Intent("/"); ComponentName comp = new ComponentName("com.android.phone", "com.android.phone.Settings"); mIntent.setComponent(comp); mIntent.setAction("android.intent.action.VIEW"); context.startActivity(mIntent);//from ww w.j a v a 2 s .c om }
From source file:Main.java
public static void openSetting(Activity activity, int requestCode) { Intent intent = new Intent("/"); ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); intent.setComponent(cm); intent.setAction(Intent.ACTION_VIEW); activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void openNetworkSetting(Activity activity) { Intent intent = new Intent("/"); ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); intent.setComponent(cm); intent.setAction("android.intent.action.VIEW"); activity.startActivityForResult(intent, 0); }
From source file:Main.java
public static void openSetting(Activity activity) { Intent intent = new Intent("/"); ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); intent.setComponent(cm); intent.setAction("android.intent.action.VIEW"); activity.startActivityForResult(intent, 0); }
From source file:Main.java
public static void openNet(Activity activity) { Intent intent = new Intent("/"); ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); intent.setComponent(cm); intent.setAction("android.intent.action.VIEW"); activity.startActivityForResult(intent, 0); }
From source file:net.nym.utilslibrary.utils.IntentUtils.java
public static void openActivity(Context context, String packageName, String cls) { try {/*ww w . ja v a 2 s . co m*/ ComponentName componet = new ComponentName(packageName, cls); Intent intent = new Intent(); intent.setComponent(componet); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.nym.utilslibrary.utils.IntentUtils.java
public static void openApp(Context context, String packageName, String cls) { try {/* w ww. j a v a 2s . c o m*/ ComponentName componet = new ComponentName(packageName, cls); Intent intent = new Intent(); intent.setComponent(componet); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); Toaster.toaster(context, "?APP"); } }