List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:Main.java
public static void pickAudio(Activity activity, int resultCode) { Intent intent = new Intent(); intent.setType("audio/*"); intent.setAction(Intent.ACTION_GET_CONTENT); activity.startActivityForResult(intent, resultCode); }
From source file:Main.java
public static void createDeskShortCut(Context cxt, String shortCutName, int icon, Class<?> cls) { Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortcutIntent.putExtra("duplicate", false); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortCutName); Parcelable ico = Intent.ShortcutIconResource.fromContext(cxt.getApplicationContext(), icon); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ico); Intent intent = new Intent(cxt, cls); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); cxt.sendBroadcast(shortcutIntent);//from w w w .j ava 2s . co m }
From source file:Main.java
public static void getPhotoFromCamera(Activity context, int requestCode, Uri imageUri) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // set the image file name context.startActivityForResult(intent, requestCode); }
From source file:Main.java
private static void setBadgeSony(Context context, int count) { String launcherClassName = getLauncherClassName(context); if (launcherClassName == null) { return;// w w w . ja v a2s.com } 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
/** * @deprecated/*from w w w . j av a 2 s . co m*/ * use isGooglePlayInstalled(Context ctx) instead * @param ctx * @return */ public static boolean isAndroidMarketInstalled(Context ctx) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=foo")); PackageManager pm = ctx.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(intent, 0); if (list.size() > 0) { return true; } else { return false; } }
From source file:Main.java
public static void openImageAction(Activity activity, int requestCode) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void startInstalledAppDetailsActivity(@Nullable final Activity context) { if (context == null) { return;/* ww w . j a v a 2 s . c o m*/ } final Intent i = new Intent(); i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + context.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(i); }
From source file:Main.java
public static void choosePicture(Context context) { Intent intent3 = new Intent(); intent3.setType("image/*"); intent3.setAction(Intent.ACTION_GET_CONTENT); ((Activity) context).startActivityForResult(intent3, REQUEST_CHOOSE); }
From source file:Main.java
public static void callBrowser(Context context, String uri) { Intent intent = new Intent(); intent.setData(Uri.parse(uri));/*from ww w . j av a 2 s . c om*/ intent.setAction(Intent.ACTION_VIEW); context.startActivity(intent); }
From source file:Main.java
/** * Broadcast data as a message// w ww. ja v a2 s. c o m * * @param context * the context * @param data * the data * @param action * the action * @param custompermission * the custompermission */ public static void broadcastData(Context context, String data, String action, String custompermission) { Intent i = new Intent(); i.putExtra("data", data); i.setAction(action); // action ~ "com.example.android.action" context.sendBroadcast(i, custompermission); // custompermisson ~ "com.example.permission.MY_PERMISSION" }