List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
/** * Start activity from SideNavigation./* w w w . j a va 2 s .c o m*/ * * @param title title of Activity * @param resId resource if of background image */ private void invokeActivity(String title, int resId) { Intent intent = new Intent(this, MainActivity.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); // no animation of transition overridePendingTransition(0, 0); }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
private void invokeActivity1(String title, int resId) { Intent intent = new Intent(this, BaseMenuActivity.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);//from w w w.j ava2 s . co m // no animation of transition overridePendingTransition(0, 0); }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
private void invokeActivity2(String title, int resId) { Intent intent = new Intent(this, baseMenuActivity2.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/*from ww w . j a v a2s. c o m*/ // no animation of transition overridePendingTransition(0, 0); }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
private void invokeActivity3(String title, int resId) { Intent intent = new Intent(this, baseMenuActivity3.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/*from www . java2s.c o m*/ // no animation of transition overridePendingTransition(0, 0); }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
private void invokeActivity4(String title, int resId) { Intent intent = new Intent(this, baseMenuActivity4.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/*w w w. j a va2s . com*/ // no animation of transition overridePendingTransition(0, 0); }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
private void invokeActivity5(String title, int resId) { Intent intent = new Intent(this, baseMenuActivity5.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/* w w w.java 2 s .c o m*/ // no animation of transition overridePendingTransition(0, 0); }
From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java
private void updateButtonOpenLink() { final View btnOpenLink = menu.findViewById(R.id.BtnOpenLink); btnOpenLink.setOnClickListener(new OnClickListener() { @Override/* w w w . ja v a 2s .c om*/ public void onClick(final View view) { if (listener != null) { final SettingBrowserChoice setting = new SettingBrowserChoice(dataMgr); switch (setting.getData()) { case SettingBrowserChoice.BROWSER_CHOICE_UNKNOWN: final LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Dialog)); final View popupView = inflater.inflate(R.layout.browser_choice_popup, null); final CheckBox checkBox = (CheckBox) popupView.findViewById(R.id.CheckBoxDontShowAgain); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { popupView.findViewById(R.id.Hint).setVisibility(View.VISIBLE); } }); final String items[] = new String[3]; items[0] = context.getString(R.string.TxtBuiltInMobilized); items[1] = context.getString(R.string.TxtBuiltInOriginal); items[2] = context.getString(R.string.TxtExternalOriginal); builder.setTitle(R.string.TxtChooseBrowser); builder.setView(popupView); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { switch (which) { case 0: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED); } dialog.dismiss(); break; case 1: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL); } dialog.dismiss(); break; case 2: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL); } dialog.dismiss(); break; default: break; } } }); builder.setNegativeButton(context.getString(R.string.TxtCancel), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); builder.show(); break; case SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); break; case SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } break; case SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } break; default: break; } } } }); }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private boolean donateViaWeChat() { File qrCode = getQrCode();/*from w w w. ja v a 2s . c om*/ if (qrCode == null) { return false; } try { FileUtils.dumpFile(getAssets().open("wechat.png"), qrCode); } catch (IOException e) { UILog.d("cannot dump wechat", e); return false; } refreshQrCode(qrCode); showDonateDialog(); Intent intent = new Intent("com.tencent.mm.action.BIZSHORTCUT"); intent.setPackage("com.tencent.mm"); intent.putExtra("LauncherUI.From.Scaner.Shortcut", true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); try { startActivity(intent); for (int i = 0; i < 0x3; ++i) { Toast.makeText(this, R.string.select_qr_code, Toast.LENGTH_LONG).show(); } } catch (Throwable t) { // NOSONAR hideDonateDialog(); } return true; }
From source file:com.phonegap.cordova.FileOpener.java
private void openFile(String url, String type) throws IOException { // Create URI Uri uri = Uri.parse(url);/* w w w .jav a 2s . c o m*/ Intent intent = null; Log.v("FileOpener", "Type: " + type); if (type.equals("pdfshare")) { intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); // intent.setDataAndType(uri, "application/pdf"); intent.setType("application/pdf"); intent.putExtra(Intent.EXTRA_SUBJECT, "AMR Report"); intent.putExtra(Intent.EXTRA_TEXT, ""); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else if (url.contains(".pdf")) { // PDF file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/pdf"); } else if (url.contains(".ppt") || url.contains(".pptx")) { // Powerpoint file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if (url.contains(".xls") || url.contains(".xlsx")) { // Excel file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if (url.contains(".rtf")) { // RTF file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/rtf"); } else if (url.contains(".wav")) { // WAV audio file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "audio/x-wav"); } else if (url.contains(".gif")) { // GIF file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "image/gif"); } else if (url.contains(".jpg") || url.contains(".jpeg")) { // JPG file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "image/jpeg"); } else if (url.contains(".png")) { // PNG file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "image/png"); } else if (url.contains(".txt")) { // Text file intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "text/plain"); } else if (url.contains(".mpg") || url.contains(".mpeg") || url.contains(".mpe") || url.contains(".mp4") || url.contains(".avi")) { // Video files intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/*"); } else if (url.contains(".doc") || url.contains(".docx")) { // Word document intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/msword"); } //if you want you can also define the intent type for any other file //additionally use else clause below, to manage other unknown extensions //in this case, Android will show all applications installed on the device //so you can choose which application to use else if (type.equals("none") || type.equals("*/*")) { intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "*/*"); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(uri, type); } //TRY Catch error try { this.cordova.getActivity().startActivity(intent); } catch (ActivityNotFoundException e) { intent.setData(uri); this.cordova.getActivity().startActivity(intent); } }
From source file:com.ohnemax.android.glass.doseview.CSDataSort.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (mLiveCard == null) { // Get an instance of a live card mLiveCard = new LiveCard(this, LIVE_CARD_TAG); // Inflate a layout into a remote view mLiveCardView = new RemoteViews(getPackageName(), R.layout.service_doserate); // Set up the live card's action with a pending intent // to show a menu when tapped Intent menuIntent = new Intent(this, MenuActivity.class); menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0)); // Publish the live card mLiveCard.publish(PublishMode.REVEAL); // Queue the update text runnable mHandler.post(mUpdateLiveCardRunnable); }// w ww.ja v a2s. co m return START_STICKY; }