List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.e2g.ecocicle.barcode.IntentIntegrator.java
/** * Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings corresponding * to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants * like {@link #PRODUCT_CODE_TYPES} for example. * * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for * @param cameraId camera ID of the camera to use. A negative value means "no preference". * @return the {@link android.app.AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise *//*from w ww. j av a 2 s . c o m*/ public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats, int cameraId) { Intent intentScan = new Intent(BS_PACKAGE + ".SCAN"); intentScan.addCategory(Intent.CATEGORY_DEFAULT); // check which types of codes to scan for if (desiredBarcodeFormats != null) { // set the desired barcode types StringBuilder joinedByComma = new StringBuilder(); for (String format : desiredBarcodeFormats) { if (joinedByComma.length() > 0) { joinedByComma.append(','); } joinedByComma.append(format); } intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString()); } // check requested camera ID if (cameraId >= 0) { intentScan.putExtra("SCAN_CAMERA_ID", cameraId); } String targetAppPackage = findTargetAppPackage(intentScan); if (targetAppPackage == null) { return showDownloadDialog(); } intentScan.setPackage(targetAppPackage); intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intentScan); startActivityForResult(intentScan, REQUEST_CODE); return null; }
From source file:com.fatelon.partyphotobooth.setup.fragments.EventInfoSetupFragment.java
/** * Starts the {@link Activity} for event logo selection. * * @param context the {@link Context}./* ww w . j a v a 2s . c o m*/ */ private void launchLogoSelection(Context context) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(EVENT_LOGO_MIME_TYPE); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); Intent chooserIntent = Intent.createChooser(intent, context.getString(R.string.event_info_setup__event_logo_chooser_title)); startActivityForResult(chooserIntent, EVENT_LOGO_REQUEST_CODE); }
From source file:com.amrutpatil.makeanote.NotesActivity.java
@Override public void onBackPressed() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);//from w ww .ja v a 2 s . co m }
From source file:net.helff.wificonnector.WifiConnectivityService.java
protected void sendNotification(String msg) { Log.i(TAG, "send notification: " + msg); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.launchericon, msg, System.currentTimeMillis()); Intent intent = new Intent(this, WifiConnectorActivity.class); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); notification.setLatestEventInfo(this.getApplicationContext(), "WifiConnector", msg, pendingIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(1, notification); }
From source file:com.fa.mastodon.activity.EditProfileActivity.java
private void initiateMediaPicking() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); switch (currentlyPicking) { case AVATAR: { startActivityForResult(intent, AVATAR_PICK_RESULT); break;//from w w w .j a v a2 s . c o m } case HEADER: { startActivityForResult(intent, HEADER_PICK_RESULT); break; } } }
From source file:com.pvo.activity.MainFragmentActivity.java
@Override public void onBackPressed() { if (fragmentStack.size() > 1) { System.out.println("--> On back press if condition <---"); FragmentTransaction ft = fragmentManager.beginTransaction(); if (ft != null) { fragmentStack.lastElement().onPause(); ft.remove(fragmentStack.pop()); Fragment lastFragment = fragmentStack.lastElement(); lastFragment.onResume();//from w w w. j a va2 s. c o m ft.show(lastFragment); ft.commit(); } } else { System.out.println("--> On back press else condition <---"); Fragment visible = getVisibleFragment(); if (visible instanceof ZNotificationMainFragment) { clearStoreData(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { redirectToNotificaiton(); } } }
From source file:com.github.dfa.diaspora_android.activity.ShareActivity2.java
@SuppressLint("SetJavaScriptEnabled") @Override/*w w w . j a v a 2s.co m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); progressBar = (ProgressBar) findViewById(R.id.progressBar); swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe); swipeView.setEnabled(false); toolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (Helpers.isOnline(ShareActivity2.this)) { Intent intent = new Intent(ShareActivity2.this, MainActivity.class); startActivityForResult(intent, 100); overridePendingTransition(0, 0); } else { Snackbar.make(swipeView, R.string.no_internet, Snackbar.LENGTH_LONG).show(); } } }); podDomain = ((App) getApplication()).getSettings().getPodDomain(); fab = (com.getbase.floatingactionbutton.FloatingActionsMenu) findViewById(R.id.fab_expand_menu_button); fab.setVisibility(View.GONE); webView = (WebView) findViewById(R.id.webView); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); WebSettings wSettings = webView.getSettings(); wSettings.setJavaScriptEnabled(true); wSettings.setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT >= 21) wSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); /* * WebViewClient */ webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d(TAG, url); if (!url.contains(podDomain)) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); return true; } return false; } public void onPageFinished(WebView view, String url) { Log.i(TAG, "Finished loading URL: " + url); } }); /* * WebChromeClient */ webView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView wv, int progress) { progressBar.setProgress(progress); if (progress > 0 && progress <= 60) { Helpers.getNotificationCount(wv); } if (progress > 60) { Helpers.hideTopBar(wv); } if (progress == 100) { progressBar.setVisibility(View.GONE); } else { progressBar.setVisibility(View.VISIBLE); } } @Override public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { if (mFilePathCallback != null) mFilePathCallback.onReceiveValue(null); mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Snackbar.make(getWindow().findViewById(R.id.drawer_layout), "Unable to get image", Snackbar.LENGTH_SHORT).show(); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } }); Intent intent = getIntent(); final Bundle extras = intent.getExtras(); String action = intent.getAction(); if (Intent.ACTION_SEND.equals(action)) { webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { if (extras.containsKey(Intent.EXTRA_TEXT) && extras.containsKey(Intent.EXTRA_SUBJECT)) { final String extraText = (String) extras.get(Intent.EXTRA_TEXT); final String extraSubject = (String) extras.get(Intent.EXTRA_SUBJECT); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { finish(); Intent i = new Intent(ShareActivity2.this, MainActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); overridePendingTransition(0, 0); return false; } }); webView.loadUrl("javascript:(function() { " + "document.getElementsByTagName('textarea')[0].style.height='110px'; " + "document.getElementsByTagName('textarea')[0].innerHTML = '**[" + extraSubject + "]** " + extraText + " *[shared with #DiasporaWebApp]*'; " + " if(document.getElementById(\"main_nav\")) {" + " document.getElementById(\"main_nav\").parentNode.removeChild(" + " document.getElementById(\"main_nav\"));" + " } else if (document.getElementById(\"main-nav\")) {" + " document.getElementById(\"main-nav\").parentNode.removeChild(" + " document.getElementById(\"main-nav\"));" + " }" + "})();"); } } }); } if (savedInstanceState == null) { if (Helpers.isOnline(ShareActivity2.this)) { webView.loadUrl("https://" + podDomain + "/status_messages/new"); } else { Snackbar.make(getWindow().findViewById(R.id.drawer_layout), R.string.no_internet, Snackbar.LENGTH_SHORT).show(); } } }
From source file:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void open() { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); PoemFile poemFile = mPoemPrefs.getSavedPoem(); if (poemFile != null) intent.setData(poemFile.uri);//from www. j a v a 2 s . c o m intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); startActivityForResult(intent, ACTION_FILE_OPEN); }
From source file:com.cleanwiz.applock.ui.activity.SplashActivity.java
public void createDeskShortCut() { // ????/*from w ww. ja v a2 s. c o m*/ SharedPreferenceUtil.editShortCut(true); Intent shortcutIntent = new Intent(); shortcutIntent.setClass(this, SplashActivity.class); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); shortcutIntent.setAction("android.intent.action.MAIN"); shortcutIntent.addCategory("android.intent.category.LAUNCHER"); Intent resultIntent = new Intent(); resultIntent.putExtra("duplicate", false); resultIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); resultIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); resultIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); resultIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); sendBroadcast(resultIntent); resultIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(resultIntent); }
From source file:com.example.yuen.e_carei.ShowAppointmentList.java
private void open(ApplicationInfo item) { // open app/*from w ww . j a v a2 s . co m*/ Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(item.packageName); List<ResolveInfo> resolveInfoList = getPackageManager().queryIntentActivities(resolveIntent, 0); if (resolveInfoList != null && resolveInfoList.size() > 0) { ResolveInfo resolveInfo = resolveInfoList.get(0); String activityPackageName = resolveInfo.activityInfo.packageName; String className = resolveInfo.activityInfo.name; Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName componentName = new ComponentName(activityPackageName, className); intent.setComponent(componentName); startActivity(intent); } }