List of usage examples for android.content Intent setComponent
public @NonNull Intent setComponent(@Nullable ComponentName component)
From source file:Main.java
/** * Load the settings activity of a particular joyn client to enable or * disable the client// ww w .j a va2 s.c o m * * @param context Application context * @param appInfo Application info */ public static void loadJoynClientSettings(Context context, ResolveInfo appInfo) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName(appInfo.activityInfo.packageName, appInfo.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); context.startActivity(intent); }
From source file:Main.java
public static void startActivity(Context mContext, String packageName, String className) { try {//from w w w . j a v a 2s . co m ComponentName com = new ComponentName(packageName, className); Intent intent = new Intent(); intent.setComponent(com); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static List<Intent> createTakePictureIntentList(@NonNull Context context, @NonNull Uri outputFileUri) { List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { String packageName = res.activityInfo.packageName; Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName);//ww w. j a v a2 s . c om intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(intent); } return cameraIntents; }
From source file:org.opensilk.music.playback.service.MediaButtonIntentReceiver.java
private static Intent copyIntent(Context context, Intent o) { Intent i = new Intent(); i.fillIn(o, 0);//from w w w. j a va2s.c o m i.setComponent(new ComponentName(context, PlaybackService.class)); i.putExtra(PlaybackConstants.FROM_MEDIA_BUTTON, true); return i; }
From source file:Main.java
public static void goProgram(Context context, String pkg, String fullclasspath) { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setComponent(new ComponentName(pkg, fullclasspath)); context.startActivity(intent);/* w w w . j av a 2 s. c o m*/ }
From source file:Main.java
public static Intent createLaunchIntent(ComponentName componentName) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(componentName); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); return intent; }
From source file:Main.java
public static void jumpToActivity(Context context, ComponentName componentName) { Intent mIntent = new Intent(); mIntent.addFlags(268435456);/*from www.j av a2 s. c o m*/ mIntent.setComponent(componentName); mIntent.setAction("android.intent.action.VIEW"); context.startActivity(mIntent); }
From source file:Main.java
public static void jumpToActivity(Context context, ComponentName componentName, String... datas) { Intent mIntent = new Intent(); mIntent.addFlags(268435456);/* w ww .ja v a 2 s. co 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:Main.java
public static void runApp(Context context, String paramString) { PackageManager localPackageManager = context.getPackageManager(); try {//from ww w .j a v a 2 s . c om PackageInfo localPackageInfo = localPackageManager.getPackageInfo(paramString, 0); Intent localIntent1 = new Intent("android.intent.action.MAIN", null); localIntent1.setPackage(localPackageInfo.packageName); ResolveInfo localResolveInfo = (ResolveInfo) localPackageManager.queryIntentActivities(localIntent1, 0) .iterator().next(); if (localResolveInfo != null) { String str1 = localResolveInfo.activityInfo.packageName; String str2 = localResolveInfo.activityInfo.name; Intent localIntent2 = new Intent("android.intent.action.MAIN"); localIntent2.setComponent(new ComponentName(str1, str2)); context.startActivity(localIntent2); } } catch (PackageManager.NameNotFoundException localNameNotFoundException) { localNameNotFoundException.printStackTrace(); } }
From source file:Main.java
public static Intent getImageFromGalleryCamera(Context context) { // Determine Uri of camera image to save. File root = new File( Environment.getExternalStorageDirectory() + File.separator + "dianta/camera" + File.separator); root.mkdirs();//from w ww . j a v a2 s.c om String fname = "dianta-" + System.currentTimeMillis() + ".jpg"; File sdImageMainDirectory = new File(root, fname); Uri outputFileUri = Uri.fromFile(sdImageMainDirectory); // camera List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager lPackageManager = context.getPackageManager(); List<ResolveInfo> listCam = lPackageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo rInfo : listCam) { String packageName = rInfo.activityInfo.packageName; Intent lIntent = new Intent(captureIntent); lIntent.setComponent(new ComponentName(rInfo.activityInfo.packageName, rInfo.activityInfo.name)); lIntent.setPackage(packageName); //save camera result to external storage lIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(lIntent); } //ugly hacks for camera helper lastCameraImageSaved = outputFileUri; // gallery Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); Intent chooserIntent = Intent.createChooser(galleryIntent, "Pilih Sumber"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); return chooserIntent; }