Java Code Examples for android.content.Intent#addCategory()
The following examples show how to use
android.content.Intent#addCategory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
private void listing6_10() { // Listing 6-10: Generating a list of possible actions // to be performed on specific data PackageManager packageManager = getPackageManager(); // Create the intent used to resolve which actions should appear in the menu. Intent intent = new Intent(); intent.setType("vnd.android.cursor.item/vnd.com.professionalandroid.provider.moonbase"); intent.addCategory(Intent.CATEGORY_SELECTED_ALTERNATIVE); // Specify flags. In this case, return all matches int flags = PackageManager.MATCH_ALL; // Generate the list List<ResolveInfo> actions; actions = packageManager.queryIntentActivities(intent, flags); // Extract the list of action names ArrayList<CharSequence> labels = new ArrayList<CharSequence>(); Resources r = getResources(); for (ResolveInfo action : actions) labels.add(action.nonLocalizedLabel); }
Example 2
Source File: BitmapUtil.java From MyHearts with Apache License 2.0 | 6 votes |
public static Intent buildImageGetIntent(Uri saveTo, int aspectX, int aspectY, int outputX, int outputY, boolean returnData) { Log.i(TAG, "Build.VERSION.SDK_INT : " + Build.VERSION.SDK_INT); Intent intent = new Intent(); if (Build.VERSION.SDK_INT < 19) { intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } intent.setType("image/*"); intent.putExtra("output", saveTo); intent.putExtra("aspectX", aspectX); intent.putExtra("aspectY", aspectY); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra("return-data", returnData); intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString()); return intent; }
Example 3
Source File: IntentIntegrator.java From 600SeriesAndroidUploader with MIT License | 6 votes |
/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); attachMoreExtras(intent); if (fragment == null) { activity.startActivity(intent); } else { fragment.startActivity(intent); } return null; }
Example 4
Source File: IntentIntegrator.java From BotLibre with Eclipse Public License 1.0 | 6 votes |
/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment == null) { activity.startActivity(intent); } else { fragment.startActivity(intent); } return null; }
Example 5
Source File: Main.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
public void run() { if (mSettings.directintent2 == null) { Intent intent = new Intent("com.adamrocker.android.simeji.ACTION_INTERCEPT"); intent.addCategory("com.adamrocker.android.simeji.REPLACE"); int startsel = mEditor.getSelectionStart(); int endsel = mEditor.getSelectionEnd(); Editable text = mEditor.getText(); String substr = ""; if (startsel != endsel) { if (endsel < startsel) { int temp = startsel; startsel = endsel; endsel = temp; } if (endsel - startsel > jp.sblo.pandora.jota.text.TextView.MAX_PARCELABLE) { Toast.makeText(Main.this, R.string.toast_overflow_of_limit, Toast.LENGTH_LONG).show(); return; } substr = text.subSequence(startsel, endsel).toString(); } intent.putExtra("replace_key", substr); try { Intent pickIntent = new Intent(Main.this, ActivityPicker.class); pickIntent.putExtra(Intent.EXTRA_INTENT, intent); mReservedIntent = intent; mReservedRequestCode = REQUESTCODE_MUSHROOM; startActivityForResult(pickIntent, REQUESTCODE_APPCHOOSER); } catch (Exception e) { } } else { sendDirectIntent(mSettings.directintent2); } }
Example 6
Source File: FileUtils.java From FileTransfer with GNU General Public License v3.0 | 5 votes |
private static Intent getExcelFileIntent(Uri uri) { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(uri, "application/vnd.ms-excel"); return intent; }
Example 7
Source File: CBrowserMainFrame.java From appcan-android with GNU Lesser General Public License v3.0 | 5 votes |
public void openFileChooser(ValueCallback<Uri> uploadMsg) { ((EBrowserActivity) mContext).setmUploadMessage(getCompatCallback(uploadMsg)); Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); ((EBrowserActivity) mContext).startActivityForResult(Intent.createChooser(i, "File Chooser"), EBrowserActivity.FILECHOOSER_RESULTCODE); }
Example 8
Source File: DeviceUtils.java From Aurora with Apache License 2.0 | 5 votes |
public static boolean isHaveMarket(Context context) { Intent intent = new Intent(); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.APP_MARKET"); PackageManager pm = context.getPackageManager(); List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0); return infos.size() > 0; }
Example 9
Source File: CommCareSessionService.java From commcare-android with Apache License 2.0 | 5 votes |
/** * Show a notification while this service is running. */ private void showLoggedInNotification(User user) { //We always want this click to simply bring the live stack back to the top Intent callable = new Intent(this, DispatchActivity.class); callable.setAction("android.intent.action.MAIN"); callable.addCategory("android.intent.category.LAUNCHER"); // The PendingIntent to launch our activity if the user selects this notification PendingIntent contentIntent = PendingIntent.getActivity(this, 0, callable, 0); String notificationText; if (AppUtils.getInstalledAppRecords().size() > 1) { try { notificationText = Localization.get("notification.logged.in", new String[]{Localization.get("app.display.name")}); } catch (NoLocalizedTextException e) { notificationText = getString(NOTIFICATION); } } else { notificationText = getString(NOTIFICATION); } // Set the icon, scrolling text and timestamp Notification notification = new NotificationCompat.Builder(this, CommCareNoficationManager.NOTIFICATION_CHANNEL_ERRORS_ID) .setContentTitle(notificationText) .setContentText("Session Expires: " + DateFormat.format("MMM dd h:mmaa", sessionExpireDate)) .setSmallIcon(org.commcare.dalvik.R.drawable.notification) .setContentIntent(contentIntent) .build(); if (user != null) { //Send the notification. this.startForeground(NOTIFICATION, notification); } }
Example 10
Source File: SetupWizardActivity.java From openboard with GNU General Public License v3.0 | 5 votes |
void invokeLanguageAndInputSettings() { final Intent intent = new Intent(); intent.setAction(Settings.ACTION_INPUT_METHOD_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); startActivity(intent); mNeedsToAdjustStepNumberToSystemState = true; }
Example 11
Source File: QRCodeScanActivity.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
private void chooseFromGallery() { try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, REQUEST_QR_IMAGE); } catch (Exception ignored) { FilePicker picker = new FilePicker(this, FilePicker.FILE); picker.setBackgroundColor(getResources().getColor(R.color.background)); picker.setTopBackgroundColor(getResources().getColor(R.color.background)); picker.setItemHeight(30); picker.setOnFilePickListener(currentPath -> zxingview.decodeQRCode(currentPath)); picker.show(); } }
Example 12
Source File: LoginActivity.java From android with MIT License | 5 votes |
private void doSelectCACertificate() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); // we don't really care what kind of file it is as long as we can parse it intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try { startActivityForResult( Intent.createChooser(intent, getString(R.string.select_ca_file)), FILE_SELECT_CODE); } catch (ActivityNotFoundException e) { // case for user not having a file browser installed Utils.showSnackBar(this, getString(R.string.please_install_file_browser)); } }
Example 13
Source File: HomeScreen.java From focus-android with Mozilla Public License 2.0 | 5 votes |
/** * Switch to the the default home screen activity (launcher). */ private static void goToHomeScreen(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
Example 14
Source File: FloatingVHPresenter.java From FastAccess with GNU General Public License v3.0 | 5 votes |
@Override public void onItemClick(int position, View v, AppsModel item) { try { Context context = v.getContext(); PackageManager manager = context.getPackageManager(); Intent intent = manager.getLaunchIntentForPackage(item.getPackageName()); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(new ComponentName(item.getPackageName(), item.getActivityInfoName())); context.startActivity(intent); } catch (Exception e) {// app uninstalled/not found e.printStackTrace(); item.delete(); } super.onItemClick(position, v, item); }
Example 15
Source File: MyX5WebChromeClient.java From ByWebView with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); mIWebPageView.startFileChooserForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); }
Example 16
Source File: SettingsFragment.java From fontster with Apache License 2.0 | 5 votes |
private boolean viewSource() { final Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse(getString(R.string.settings_link_github))); startActivity(intent); return true; }
Example 17
Source File: UpdateService.java From InviZible with GNU General Public License v3.0 | 5 votes |
private void updateNotification(int serviceStartId, int notificationId, long startTime, String Ticker, String Title, String Text, int percent) { //These three lines makes Notification to open main activity after clicking on it Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent stopDownloadIntent = new Intent(this, UpdateService.class); stopDownloadIntent.setAction(STOP_DOWNLOAD_ACTION); stopDownloadIntent.putExtra("ServiceStartId", serviceStartId); PendingIntent stopDownloadPendingIntent = PendingIntent.getService(this, notificationId, stopDownloadIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, UPDATE_CHANNEL_ID); builder.setContentIntent(contentIntent) .setOngoing(true) //Can't be swiped out .setSmallIcon(R.drawable.ic_update) .setTicker(Ticker) .setContentTitle(Title) //Заголовок .setContentText(Text) // Текст уведомления .setOnlyAlertOnce(true) .setWhen(startTime - (System.currentTimeMillis() - startTime)) .setUsesChronometer(true) .addAction(R.drawable.ic_stop, getText(R.string.cancel_download), stopDownloadPendingIntent); int PROGRESS_MAX = 100; builder.setProgress(PROGRESS_MAX, percent, false); Notification notification = builder.build(); synchronized (notificationManager) { notificationManager.notify(notificationId, notification); } }
Example 18
Source File: ActivityInvokeAPI.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * 打开某条微博正文。 * * @param activity * @param blogId 某条微博id */ public static void openDetail(Activity activity,String blogId){ if(activity==null){ return; } Intent intent=new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory("android.intent.category.DEFAULT"); intent.setData(Uri.parse("sinaweibo://detail?mblogid="+blogId)); activity.startActivity(intent); }
Example 19
Source File: ProgressWebView.java From Android-Application-ZJB with Apache License 2.0 | 5 votes |
private void openFileChooserImpl(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); Activity activity = (Activity) getContext(); activity.startActivityForResult(Intent.createChooser(i, "File Chooser"), BaseWebActivity.FILE_CHOOSER_RESULTCODE); }
Example 20
Source File: GetAppList.java From android-tv-launcher with MIT License | 4 votes |
public ArrayList<AppBean> getLaunchAppList() { PackageManager localPackageManager = mContext.getPackageManager(); Intent localIntent = new Intent("android.intent.action.MAIN"); localIntent.addCategory("android.intent.category.LAUNCHER"); List<ResolveInfo> localList = localPackageManager.queryIntentActivities(localIntent, 0); ArrayList<AppBean> localArrayList = null; Iterator<ResolveInfo> localIterator = null; if (localList != null) { localArrayList = new ArrayList<AppBean>(); localIterator = localList.iterator(); } while (true) { if (!localIterator.hasNext()) break; ResolveInfo localResolveInfo = (ResolveInfo) localIterator.next(); AppBean localAppBean = new AppBean(); localAppBean.setIcon(localResolveInfo.activityInfo.loadIcon(localPackageManager)); localAppBean.setName(localResolveInfo.activityInfo.loadLabel(localPackageManager).toString()); localAppBean.setPackageName(localResolveInfo.activityInfo.packageName); localAppBean.setDataDir(localResolveInfo.activityInfo.applicationInfo.publicSourceDir); localAppBean.setLauncherName(localResolveInfo.activityInfo.name); String pkgName = localResolveInfo.activityInfo.packageName; PackageInfo mPackageInfo; try { mPackageInfo = mContext.getPackageManager().getPackageInfo(pkgName, 0); if ((mPackageInfo.applicationInfo.flags & mPackageInfo.applicationInfo.FLAG_SYSTEM) > 0) {//系统预装 localAppBean.setSysApp(true); } } catch (NameNotFoundException e) { e.printStackTrace(); } String noSeeApk = localAppBean.getPackageName(); // 屏蔽自己 、芒果 、tcl新 if (!noSeeApk.equals("com.cqsmiletv") && !noSeeApk.endsWith("com.starcor.hunan") && !noSeeApk.endsWith("com.tcl.matrix.tventrance")) { localArrayList.add(localAppBean); } } return localArrayList; }