List of usage examples for android.content Intent CATEGORY_LAUNCHER
String CATEGORY_LAUNCHER
To view the source code for android.content Intent CATEGORY_LAUNCHER.
Click Source Link
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; }/* ww w . j av a 2 s.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 a v a2 s. co m*/ 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
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; }// w w w .j a v a2 s . c om } return null; }
From source file:Main.java
/** * @param context/*from ww w . ja v a 2s. c o m*/ * 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; } }
From source file:Main.java
/** * Returns an intent to start K-9 Mail.//from www .ja va 2s. c o m * * @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 List<ResolveInfo> getAllAppInfo(Context context) { try {// ww w . j a v a2 s .c o m Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> appList = context.getPackageManager().queryIntentActivities(mainIntent, 0); return appList; } catch (Exception e) { e.printStackTrace(); } return null; }
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; }/* w w w.j a v a 2 s .c om*/ } return null; }
From source file:Main.java
private static void shareImageOnFacebook(String imagePath, Context context) { Log.d("CitationsManager-ShareOnFb", "sharing the image " + imagePath); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("image/*"); // shareIntent.putExtra(Intent.EXTRA_TEXT, "www.google.com"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath))); PackageManager pm = context.getPackageManager(); List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0); for (final ResolveInfo app : activityList) { Log.d("CitationsManager-ShareOnFb", app.activityInfo.name); if ((app.activityInfo.name).contains("com.facebook") && !(app.activityInfo.name).contains("messenger") && !(app.activityInfo.name).contains("pages")) { final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name); shareIntent.addCategory(Intent.CATEGORY_LAUNCHER); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); shareIntent.setComponent(name); context.startActivity(shareIntent); break; }//ww w.ja va 2 s . c o m } }
From source file:Main.java
/** * Retrieve launcher activity name of the application from the context * * @param context The context of the application package. * @return launcher activity name of this application. From the * "android:name" attribute.// ww w . ja v a 2 s. c o m */ private static String getLauncherClassName(Context context) { PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); // To limit the components this Intent will resolve to, by setting an // explicit package name. intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_LAUNCHER); // All Application must have 1 Activity at least. // Launcher activity must be found! ResolveInfo info = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); // get a ResolveInfo containing ACTION_MAIN, CATEGORY_LAUNCHER // if there is no Activity which has filtered by CATEGORY_DEFAULT if (info == null) { info = packageManager.resolveActivity(intent, 0); } return info.activityInfo.name; }
From source file:org.iota.wallet.helper.NotificationHelper.java
public static void responseNotification(Context context, int image, String title, int id) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { createNotificationChannel(context); }//from www. j ava2 s . c om notificationManager = (NotificationManager) context.getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); long[] vibrateLength = { 500, 1000 }; Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.setAction(Constants.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(context, id, notificationIntent, 0); Notification notification = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL) .setSmallIcon(image).setColor(ContextCompat.getColor(context, R.color.colorAccent)) .setContentTitle(title).setContentIntent(pendingIntent).setVibrate(vibrateLength) .setAutoCancel(true).build(); notificationManager.notify(id, notification); }