List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:Main.java
/** * @param context used to check the device version and DownloadManager information * @return true if the download manager is available *//*from w w w .j a v a 2s . c om*/ //http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog public static boolean isDownloadManagerAvailable() { try { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { return false; } Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList"); List<ResolveInfo> list = m_TempContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; } catch (Exception e) { return false; } }
From source file:Main.java
public static Intent getSmsIntent() { Intent conversations = new Intent(Intent.ACTION_MAIN); //conversations.addCategory(Intent.CATEGORY_DEFAULT); conversations.setType(SMS_MIME_TYPE); // should I be using FLAG_ACTIVITY_RESET_TASK_IF_NEEDED?? int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP; conversations.setFlags(flags);//from w w w. j a va2 s. c om return conversations; }
From source file:Main.java
public static String getCurLauncher(Context context) { if (context == null) { return null; }/* w w w. jav a2 s. co m*/ try { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_HOME); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(mainIntent, 0); if (resolveInfo != null) { return resolveInfo.activityInfo.packageName; } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Intent getGalleryIntent(Context context) { return new Intent(Intent.ACTION_MAIN).setClassName(GALLERY_PACKAGE_NAME, GALLERY_ACTIVITY_CLASS); }
From source file:Main.java
public static String getLauncherClassName(Context context) { PackageManager pm = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : resolveInfos) { String pkgName = resolveInfo.activityInfo.applicationInfo.packageName; if (pkgName.equalsIgnoreCase(context.getPackageName())) { String className = resolveInfo.activityInfo.name; return className; }/*from ww w . j av a 2s .c om*/ } return null; }
From source file:Main.java
public static void delShortcutFromDesktop(Context paramContext, String packageName, String cls, String appName) {//from w w w .j av a2s. c om Intent localIntent1 = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT"); String str = appName; PackageManager localPackageManager = paramContext.getPackageManager(); int i = 8320; try { ApplicationInfo localApplicationInfo = localPackageManager.getApplicationInfo(packageName, i); if (str == null) str = localPackageManager.getApplicationLabel(localApplicationInfo).toString(); localIntent1.putExtra("android.intent.extra.shortcut.NAME", str); ComponentName localComponentName = new ComponentName(packageName, cls); Intent localIntent2 = new Intent(Intent.ACTION_MAIN).setComponent(localComponentName); localIntent2.addCategory(Intent.CATEGORY_LAUNCHER); localIntent1.putExtra("android.intent.extra.shortcut.INTENT", localIntent2); paramContext.sendBroadcast(localIntent1); return; } catch (PackageManager.NameNotFoundException localNameNotFoundException) { while (true) localNameNotFoundException.printStackTrace(); } }
From source file:Main.java
public static String getLauncherPackageName(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo.activityInfo.packageName; }
From source file:Main.java
private static String getLauncherClassName(Context context) { PackageManager pm = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : resolveInfos) { String pkgName = resolveInfo.activityInfo.applicationInfo.packageName; if (pkgName.equalsIgnoreCase(context.getPackageName())) { String className = resolveInfo.activityInfo.name; return className; }//from w w w.j a va 2s. co m } return null; }
From source file:Main.java
public static boolean onKeyBackGoHome(Activity activity, int keyCode, KeyEvent event) { if (!(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)) { return false; // continue }// ww w. j av a 2s . co m activity.startActivity(new Intent().setAction(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)); return true; }
From source file:Main.java
/** * @param context//from w w w . j a v a 2 s . com * used to check the device version and DownloadManager * information * @return true if the download manager is available */ public static boolean isDownloadManagerAvailable(Context context) { try { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { return false; } Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList"); List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; } catch (Exception e) { return false; } }