List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
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
public static void installApp(Context mContext, String path) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW);/*www . j ava2s . com*/ i.addCategory(Intent.CATEGORY_DEFAULT); i.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive"); mContext.startActivity(i); }
From source file:Main.java
/** * @return the List of applications which support Mushroom protocol. *///from ww w . jav a 2 s . com public static List<ResolveInfo> getMushroomApplicationList(PackageManager packageManager) { Intent intent = new Intent(); intent.setAction(ACTION); intent.addCategory(CATEGORY); return packageManager.queryIntentActivities(intent, 0); }
From source file:Main.java
public static void sendBroadCast(Context context, String action, String key, String value) { Intent intent = new Intent(); intent.setAction(action);//from w ww.j a v a 2s . com intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(key, value); context.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadCast(Context context, String action, String key, int value) { Intent intent = new Intent(); intent.setAction(action);//from www.j av a 2s. c om intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(key, value); context.sendBroadcast(intent); }
From source file:Main.java
public static void InvokeActivity(Activity activity, Class class1) { Intent intent = new Intent(); intent.setClass(activity, class1); intent.addCategory("android.intent.category.DEFAULT"); activity.startActivity(intent);/*from w w w. jav a2 s .c o m*/ }
From source file:Main.java
public static void launchWeb(Context activityContext, String url) { //Log.d(TAG, "launchWeb::"+url); Intent in = new Intent(); in.setAction(Intent.ACTION_VIEW);/* w w w . ja va 2s . c o m*/ in.addCategory(Intent.CATEGORY_BROWSABLE); in.setData(Uri.parse(url)); activityContext.startActivity(in); }
From source file:Main.java
public static boolean isLauncherDefault(Application application) { final Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); final ResolveInfo res = application.getPackageManager().resolveActivity(intent, 0); if (res.activityInfo == null) { return false; } else if ("android".equals(res.activityInfo.packageName)) { return false; } else {/*from w w w . j a va 2 s . com*/ if (res.activityInfo.packageName.equals(application.getPackageName())) return true; else return false; } }
From source file:Main.java
public static boolean isLauncherActivity(Context context, String packageName) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mainIntent.setPackage(packageName);//from w w w . ja v a 2 s . c o m List<ResolveInfo> infoList = context.getPackageManager().queryIntentActivities(mainIntent, 0); if (infoList.isEmpty()) { return false; } else { return true; } }
From source file:Main.java
public static String getAppMainActivity(Context context, String packageName) { if (TextUtils.isEmpty(packageName)) { return ""; }//from w w w. j a v a 2 s.c o m final Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setPackage(packageName); final ResolveInfo res = context.getPackageManager().resolveActivity(intent, 0); if (res == null || res.activityInfo == null) { return ""; } return res.activityInfo.name; }