List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:com.capstonecontrol.AccountsActivity.java
/** * Sets up the 'connect' screen content. *//*from w w w .j a va 2 s . co m*/ private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { CapstoneControlActivity.userChanged = true; // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); // finish(); // clear the module list so that a new one will get found CapstoneControlActivity.modules.clear(); // instead of finish() go back to the AccountsActivity for // new login. CapstoneControlActivity.googleUserName = (String) account.getText(); Intent myIntent = new Intent(v.getContext(), SplashActivity.class); startActivity(myIntent); myIntent = new Intent(v.getContext(), CapstoneControlActivity.class); startActivity(myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); } }); } }
From source file:com.markupartist.sthlmtraveling.RouteDetailActivity.java
@Override public boolean onSearchRequested() { Intent i = new Intent(this, StartActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i);/*from w ww. j a v a 2 s . c o m*/ return true; }
From source file:com.polyvi.xface.extension.XAppExt.java
@Override public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException { XExtensionResult.Status status = XExtensionResult.Status.OK; String result = ""; try {//from ww w .j a v a 2 s.c o m if (action.equals(COMMAND_EXITAPP)) { exitApp(); } else if (COMMAND_OPEN_URL.equals(action)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String url = args.getString(0); Uri uri = getUrlFromPath(mWebContext, url); if (null == uri) { status = XExtensionResult.Status.ERROR; result = "file not exist"; return new XExtensionResult(status, result); } setDirPermisionUntilWorkspace(mWebContext, uri); setIntentByUri(intent, uri); getContext().startActivity(intent); } else if (COMMAND_INSTALL.equals(action)) { XPathResolver pathResolver = new XPathResolver(args.getString(0), mWebContext.getWorkSpace()); install(pathResolver.resolve(), callbackCtx); return new XExtensionResult(XExtensionResult.Status.NO_RESULT); } else if (COMMAND_START_SYSTEM_COMPONENT.equals(action)) { if (!startSystemComponent(args.getInt(0))) { status = XExtensionResult.Status.ERROR; result = "Unsupported component:: " + args.getString(0); } } else if (COMMAND_SET_WIFI_SLEEP_POLICY.equals(action)) { if (!setWifiSleepPolicy(args.getString(0))) { status = XExtensionResult.Status.ERROR; result = "set wifi sleep policy error"; } } else if (COMMAND_LOAD_URL.equals(action)) { boolean openExternal = Boolean.valueOf(args.getString(1)); boolean clearHistory = Boolean.valueOf(args.getString(2)); loadUrl(args.getString(0), openExternal, clearHistory, mWebContext); } else if (COMMAND_BACK_HISTORY.equals(action)) { backHistory(mWebContext); } else if (COMMAND_CLEAR_HISTORY.equals(action)) { clearHistory(mWebContext); } else if (COMMAND_CLEAR_CACHE.equalsIgnoreCase(action)) { clearCache(mWebContext); } else if (COMMAND_START_NATIVE_APP.equalsIgnoreCase(action)) { if (!XAppUtils.startNativeApp(mExtensionContext.getSystemContext().getContext(), args.getString(0), XConstant.TAG_APP_START_PARAMS, args.getString(1))) { status = XExtensionResult.Status.ERROR; } } else if (COMMAND_IS_NATIVE_APP_INSTALLED.equals(action)) { boolean installResult = false; if (isAppInstalled(args.getString(0))) { installResult = true; } return new XExtensionResult(status, installResult); } else if (COMMAND_TEL_LINK_ENABLE.equals(action)) { XConfiguration.getInstance().setTelLinkEnabled(args.optBoolean(0, true)); } else if (COMMAND_QUERY_INSTALLED_NATIVEAPP.equals(action)) { return new XExtensionResult(status, queryInstalledNativeApp(args.getString(0))); } else if (COMMAND_UNINSTALL_NATIVEAPP.equals(action)) { uninstallNativeApp(args.getString(0), callbackCtx); return new XExtensionResult(XExtensionResult.Status.NO_RESULT); } else { status = XExtensionResult.Status.INVALID_ACTION; result = "Unsupported Operation: " + action; } return new XExtensionResult(status, result); } catch (IllegalArgumentException e) { e.printStackTrace(); return new XExtensionResult(XExtensionResult.Status.ERROR); } }
From source file:com.github.barcodeeye.scan.CaptureActivity.java
private void handleDecodeInternally(Result rawResult, Bitmap barcode) { Uri imageUri = null;/*from w ww . j ava2 s. c o m*/ String imageName = IMAGE_PREFIX + System.currentTimeMillis() + ".png"; Log.v(TAG, "Saving image as: " + imageName); try { imageUri = mImageManager.saveImage(imageName, barcode); } catch (IOException e) { Log.e(TAG, "Failed to save image!", e); } ResultProcessor<?> processor = ResultProcessorFactory.makeResultProcessor(this, rawResult, imageUri); if (!validateQRcode(rawResult.toString())) { Toast.makeText(getApplicationContext(), "Invalid QR code!", Toast.LENGTH_SHORT).show(); onResume(); } else { File f = new File(getCacheDir(), "LoginData.txt"); FileOutputStream fos = null; try { if (!f.exists()) { f.createNewFile(); } fos = new FileOutputStream(f, false); fos.write(rawResult.toString().getBytes()); fos.close(); } catch (IOException e) { Log.e(TAG, "Failed to save Login!", e); } // Intent Creation and Initialization Intent intent = new Intent(context2, InformationPreviewActivity.class); //I have added the line: (flags) (for closing the first activity) intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Create a Bundle and Put Bundle into it (SENDS PERSON) Bundle bundleObject = new Bundle(); bundleObject.putSerializable("key", rawResult.toString()); // Put Bundle into Intent and call start Activity intent.putExtras(bundleObject); startActivity(intent); //I have added the line: (finish) (for closing the first activity) finish(); } // startActivity(ResultsActivity.newIntent(this,processor.getCardResults())); }
From source file:com.timrae.rikaidroid.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView = (WebView) findViewById(R.id.webview); mWebClient = new WebViewClient() { @Override/*from ww w . j a v a 2 s . c o m*/ public boolean shouldOverrideUrlLoading(WebView view, String url) { Uri uri = Uri.parse(url); if (uri.getScheme().equals("lookup")) { String query = uri.getHost(); Intent i = new Intent(AEDICT_INTENT); i.putExtra("kanjis", query); i.putExtra("showEntryDetailOnSingleResult", true); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); view.reload(); return true; } else { view.loadUrl(url); } return true; } }; mWebView.setWebViewClient(mWebClient); mEditText = (EditText) findViewById(R.id.search_src_text); mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); if (mProgressBar != null) { mProgressBar.setVisibility(View.VISIBLE); } }
From source file:io.github.pwlin.cordova.plugins.fileopener2.FileOpener2.java
private void _open(String fileArg, String contentType, CallbackContext callbackContext) throws JSONException { String fileName = ""; try {//from ww w . ja v a 2 s. c om CordovaResourceApi resourceApi = webView.getResourceApi(); Uri fileUri = resourceApi.remapUri(Uri.parse(fileArg)); fileName = this.stripFileProtocol(fileUri.toString()); } catch (Exception e) { fileName = fileArg; } File file = new File(fileName); if (file.exists()) { try { Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); if (Build.VERSION.SDK_INT >= 24) { Context context = cordova.getActivity().getApplicationContext(); path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".opener.provider", file); intent.setDataAndType(path, contentType); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); List<ResolveInfo> infoList = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : infoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, path, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } } else { intent.setDataAndType(path, contentType); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } /* * @see * http://stackoverflow.com/questions/14321376/open-an-activity-from-a-cordovaplugin */ cordova.getActivity().startActivity(intent); //cordova.getActivity().startActivity(Intent.createChooser(intent,"Open File in...")); callbackContext.success(); } catch (android.content.ActivityNotFoundException e) { JSONObject errorObj = new JSONObject(); errorObj.put("status", PluginResult.Status.ERROR.ordinal()); errorObj.put("message", "Activity not found: " + e.getMessage()); callbackContext.error(errorObj); } } else { JSONObject errorObj = new JSONObject(); errorObj.put("status", PluginResult.Status.ERROR.ordinal()); errorObj.put("message", "File not found"); callbackContext.error(errorObj); } }
From source file:com.arthackday.killerapp.GCMIntentService.java
@Override protected void onMessage(Context ctxt, Intent message) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh GCMessage"); Bundle extras = message.getExtras(); /*/*from w w w . j av a 2 s .c o m*/ * TO DO! CHANGE WHAT THE MESSAGES DO!! */ for (String key : extras.keySet()) { Log.i(getClass().getSimpleName(), String.format("onMessage: %s=%s", key, extras.getString(key))); if (key.equals(KillerConstants.EXTRA_KEY_AUDIO)) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh pushAudio"); Intent i = new Intent(); Log.i("REMOVE BEFORE COMMIT", extras.getString(key)); Bundle bundle = new Bundle(); //Add your data to bundle bundle.putString(KillerConstants.EXTRA_KEY_AUDIO, extras.getString(key)); //Add the bundle to the intent i.putExtras(bundle); i.setClassName("com.arthackday.killerapp", "com.arthackday.killerapp.PushAudio"); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } if (key.equals(KillerConstants.EXTRA_KEY_PUSHCALL)) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh callnumber"); String number = extras.getString(KillerConstants.EXTRA_KEY_PUSHCALL); String uri = "tel:" + number.trim(); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(uri)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } }
From source file:com.doplgangr.secrecy.settings.SettingsFragment.java
private void confirm_stealth(String password) { final View dialogView = View.inflate(context, R.layout.dialog_confirm_stealth, null); ((TextView) dialogView.findViewById(R.id.stealth_keycode)).append(password); new AlertDialog.Builder(context).setInverseBackgroundForced(true).setView(dialogView) .setMessage(R.string.Settings__try_once_before_hide) .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context) .edit();/*from ww w .ja v a 2s. c o m*/ editor.putBoolean(Config.SHOW_STEALTH_MODE_TUTORIAL, true); editor.apply(); Intent dial = new Intent(); dial.setAction("android.intent.action.DIAL"); dial.setData(Uri.parse("tel:")); dial.setFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dial); getActivity().finish(); } }).show(); }
From source file:info.snowhow.plugin.RecorderService.java
private void showNoGPSAlert() { Log.i(LOG_TAG, "No GPS available --- show Dialog"); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("GPS is disabled on your device. Would you like to enable it?") .setCancelable(false).setPositiveButton("GPS Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); callGPSSettingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(callGPSSettingIntent); }/*w ww.j a v a 2 s.c o m*/ }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { stopRecording(); dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); alert.show(); }
From source file:com.meetingninja.csse.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SessionManager.getInstance().init(MainActivity.this); session = SessionManager.getInstance(); // Check if logged in if (!session.isLoggedIn()) { Log.v(TAG, "User is not logged in"); Intent login = new Intent(this, LoginActivity.class); // Bring login to front login.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // User cannot go back to this activity // login.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // Show no animation when launching login page login.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(login);/* w w w. j a v a 2 s. c o m*/ finish(); // close main activity } else { // Else continue Log.v(TAG, "UserID " + session.getUserID() + " is logged in"); setContentView(R.layout.activity_main); setupActionBar(); setupViews(); // on first time display view for first nav item selectItem(session.getPage()); // Check to see if data has been cached in the local database if (savedInstanceState != null) { isDataCached = savedInstanceState.getBoolean(KEY_SQL_CACHE, false); } if (!isDataCached && session.needsSync()) { ApplicationController.getInstance().loadUsers(); isDataCached = true; session.setSynced(); } // Track the usage of the application with Parse SDK ParseAnalytics.trackAppOpened(getIntent()); ParseUser parseUser = ParseUser.getCurrentUser(); if (parseUser != null) { ParseInstallation installation = ParseInstallation.getCurrentInstallation(); installation.put("user", parseUser); installation.put("userId", parseUser.getObjectId()); installation.saveEventually(); } } }