List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:Main.java
public static void showDesk(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); context.startActivity(intent);/*from www . j av a 2 s .c o m*/ }
From source file:Main.java
public static void openFileBrowser(Activity a, int requestCode) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); a.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void goLocationSettingPage(Context context) { Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); context.startActivity(intent);/* ww w .j a v a 2 s . c om*/ // context.startActivity(new // Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS)); }
From source file:Main.java
/** * Returns an intent to start K-9 Mail./*from w w w . j a va2 s . c om*/ * * @param context * Used to retrieve the package manager. * * @return An intent to start K-9 Mail's main activity, or {@code null} in case of an error. */ public static final Intent getStartK9Intent(Context context) { try { PackageManager manager = context.getPackageManager(); Intent intent = manager.getLaunchIntentForPackage(PACKAGE_NAME); intent.addCategory(Intent.CATEGORY_LAUNCHER); return intent; } catch (Exception e) { return null; } }
From source file:Main.java
public static AlertDialog initOrbot(Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo, CharSequence stringDesiredBarcodeFormats) { Intent intentScan = new Intent("org.torproject.android.START_TOR"); intentScan.addCategory(Intent.CATEGORY_DEFAULT); try {// w w w . ja v a 2 s . c om activity.startActivityForResult(intentScan, REQUEST_CODE); return null; } catch (ActivityNotFoundException e) { return showDownloadDialog(activity, stringTitle, stringMessage, stringButtonYes, stringButtonNo); } }
From source file:Main.java
/** * open another app/*from w ww .j a v a2 s . c o m*/ * @param context * @param packageName * @throws NameNotFoundException */ public static void openApp(Context context, String packageName) throws NameNotFoundException { PackageInfo pi = context.getPackageManager().getPackageInfo(packageName, 0); Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(pi.packageName); List<ResolveInfo> apps = context.getPackageManager().queryIntentActivities(resolveIntent, 0); Iterator<ResolveInfo> iterator = apps.iterator(); while (iterator.hasNext()) { ResolveInfo ri = iterator.next(); if (ri != null) { packageName = ri.activityInfo.packageName; String className = ri.activityInfo.name; Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName cn = new ComponentName(packageName, className); intent.setComponent(cn); context.startActivity(intent); } } }
From source file:Main.java
public static void installApk(Context context, File apkfile) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.setType("application/vnd.android.package-archive"); intent.setData(Uri.fromFile(apkfile)); intent.setDataAndType(Uri.fromFile(apkfile), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);//ww w. j a v a 2 s. com }
From source file:Main.java
/** * @return an {@code Intent} to launch the given {@code packageName, name} with {@code replaceKey}. *//* w ww .ja va2 s .co m*/ public static Intent createMushroomLaunchingIntent(String packageName, String name, String replaceKey) { Intent intent = new Intent(ACTION); intent.setComponent(new ComponentName(packageName, name)); intent.addCategory(CATEGORY); intent.putExtra(KEY, replaceKey); return intent; }
From source file:Main.java
public static String getLaunchActivityName(Context context) { PackageManager localPackageManager = context.getPackageManager(); Intent localIntent = new Intent("android.intent.action.MAIN"); localIntent.addCategory("android.intent.category.LAUNCHER"); try {//from w w w .j av a 2 s . c om Iterator<ResolveInfo> localIterator = localPackageManager.queryIntentActivities(localIntent, 0) .iterator(); while (localIterator.hasNext()) { ResolveInfo localResolveInfo = localIterator.next(); if (!localResolveInfo.activityInfo.applicationInfo.packageName .equalsIgnoreCase(context.getPackageName())) continue; String str = localResolveInfo.activityInfo.name; return str; } } catch (Exception localException) { return null; } return null; }
From source file:Main.java
public static void installApk(Context context, File file) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.setType("application/vnd.android.package-archive"); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);//from w w w . j a v a2 s. c o m }