List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:Main.java
/** * Returns an intent calling the android chooser. The chooser will provide apps, which listen to one of the following actions * {@link Intent#ACTION_GET_CONTENT} , {@link MediaStore#ACTION_IMAGE_CAPTURE}, {@link MediaStore#ACTION_VIDEO_CAPTURE}, * {@link MediaStore.Audio.Media#RECORD_SOUND_ACTION} * //from ww w . ja v a 2 s . com * @return Intent that opens the app chooser. */ public static Intent getChooserIntent() { // GET_CONTENT Apps Intent getContentIntent = new Intent(); getContentIntent.setAction(Intent.ACTION_GET_CONTENT); getContentIntent.setType("*/*"); getContentIntent.addCategory(Intent.CATEGORY_OPENABLE); // ACTION_IMAGE_CAPTURE Apps Intent captureImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // ACTION_VIDEO_CAPTURE Apps Intent captureVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); // RECORD_SOUND_ACTION Apps Intent recordSoungIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); Intent finalIntent = Intent.createChooser(getContentIntent, "test"); finalIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { captureImageIntent, captureVideoIntent, recordSoungIntent }); return finalIntent; }
From source file:Main.java
public static final void openGPS(Context context) { try {//w w w.j av a2s. co m if (!isOpenGPS(context)) { Intent GPSIntent = new Intent(); GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); GPSIntent.addCategory("android.intent.category.ALTERNATIVE"); GPSIntent.setData(Uri.parse("custom:3")); PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void jumpToSystemDownloadApk(Context context, String url) { Intent intent = new Intent("android.intent.action.VIEW"); Uri data = Uri.parse(Html.fromHtml(url).toString()); intent.setData(data);/*from w w w .j a v a 2 s . co m*/ intent.setPackage("com.google.android.browser"); intent.addCategory("android.intent.category.BROWSABLE"); intent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); context.startActivity(intent); }
From source file:Main.java
/** * Get the Intent for selecting content to be used in an Intent Chooser. * //from w w w . j a va 2 s . co m * @return The intent for opening a file with Intent.createChooser() * * @author paulburke */ public static Intent createGetContentIntent() { // Implicitly allow the user to select a particular kind of data final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // The MIME data type filter intent.setType("*/*"); // Only return URIs that can be opened with ContentResolver intent.addCategory(Intent.CATEGORY_OPENABLE); return intent; }
From source file:com.fanfou.app.opensource.util.IntentHelper.java
public static Intent getLauncherIntent() { final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); return intent; }
From source file:Main.java
/** * Helper method where either the application will open the {@link Settings#ACTION_APPLICATION_DETAILS_SETTINGS} * or {@link Settings#ACTION_MANAGE_APPLICATIONS_SETTINGS} * * @param context//w w w . j a v a2 s . c o m * @return */ public static Intent getLaunchSettingsIntent(Context context) { Intent intent; try { // Direct the user to the application detail page where they can change the permissions. intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse("package:" + context.getPackageName())); } catch (ActivityNotFoundException e) { // Fails take then to the all applications screen. intent = new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); } return intent; }
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.// w ww. ja v a 2 s .c om */ 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:Main.java
public static Intent startGetPicPhotoAlbum() { Intent intent = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } else {/*from w w w. ja v a 2s . c o m*/ intent = new Intent(Intent.ACTION_GET_CONTENT); } intent.setType("image/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); return intent; }
From source file:com.android.shell.BugreportReceiver.java
/** * Build {@link Intent} that can be used to share the given bugreport. *///from w w w . j a v a 2 s .c o m private static Intent buildSendIntent(Context context, Uri bugreportUri, Uri screenshotUri) { final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setType("application/vnd.android.bugreport"); intent.putExtra(Intent.EXTRA_SUBJECT, bugreportUri.getLastPathSegment()); intent.putExtra(Intent.EXTRA_TEXT, SystemProperties.get("ro.build.description")); final ArrayList<Uri> attachments = Lists.newArrayList(bugreportUri, screenshotUri); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments); final Account sendToAccount = findSendToAccount(context); if (sendToAccount != null) { intent.putExtra(Intent.EXTRA_EMAIL, new String[] { sendToAccount.name }); } return intent; }
From source file:Main.java
/** * Gets the activity list./*from w w w. ja v a 2s.c o m*/ * * @param context * the context * @param intent * the intent * * @return the activity list */ public static List<Hashtable<String, Object>> getActivityList(Context context, Intent intent) { List<Hashtable<String, Object>> result = new ArrayList<Hashtable<String, Object>>(); PackageManager pm = context.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(intent.addCategory("android.intent.category.DEFAULT"), 0); for (ResolveInfo info : list) { Hashtable<String, Object> h = new Hashtable<String, Object>(); CharSequence labelSeq = info.activityInfo.loadLabel(pm); String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name; h.put(LABEL, label); h.put(INTENT, activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name)); result.add(h); } Collections.sort(result, displayNameComparator); return result; }