List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_TASK
int FLAG_ACTIVITY_NEW_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_NEW_TASK.
Click Source Link
From source file:com.oakesville.mythling.MediaPagerActivity.java
@Override public void onBackPressed() { if (EpgActivity.class.getName().equals(backTo) || FireTvEpgActivity.class.getName().equals(backTo)) { Intent a = new Intent(Intent.ACTION_MAIN); a.addCategory(Intent.CATEGORY_HOME); a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(a);/*from w ww . j a v a 2 s. c om*/ } else if (modeSwitch) { modeSwitch = false; Intent intent = new Intent(this, MediaPagerActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); } else { super.onBackPressed(); } }
From source file:com.cmgapps.android.util.CMGAppRater.java
/** * Shows a default {@link AlertDialog}/*from w w w . j a v a 2s .c o m*/ * * @param context A Context to show the dialog */ public void show(final Context context) { if (context == null) { throw new IllegalArgumentException("context cannot be null"); } if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("CMGAppRater.show() must be called from main thread"); } if (mDialog != null && mDialog.isShowing()) return; final Editor editor = mPref.edit(); final PackageManager pm = context.getPackageManager(); String appName; try { ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0); appName = (String) pm.getApplicationLabel(ai); } catch (NameNotFoundException e) { LOGE(TAG, "Application name can not be found"); appName = "App"; } mDialog = new AlertDialog.Builder(context).setTitle(R.string.dialog_cmgrate_title) .setMessage(context.getString(R.string.dialog_cmgrate_message, appName)).setCancelable(false) .setIcon(context.getApplicationInfo().icon) .setPositiveButton(context.getString(R.string.dialog_cmgrate_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { editor.putBoolean(APP_RATED, true); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); PreferenceEditorHelper.commit(editor); dialog.dismiss(); } }) .setNegativeButton(R.string.dialog_cmgrate_no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { PreferenceEditorHelper.commit(editor.putBoolean(DECLINED_RATE, true)); dialog.dismiss(); } }).setNeutralButton(R.string.dialog_cmgrate_later, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { PreferenceEditorHelper .commit(editor.putLong(REMIND_LATER_DATE, System.currentTimeMillis())); dialog.dismiss(); } }).show(); PreferenceEditorHelper.commit(editor); }
From source file:app.androidhive.info.realm.GCM.GcmIntentService.java
private void showJSON(String response) { String id;// ww w. ja v a2 s . co m String name = ""; String adress1 = ""; String adress2 = ""; String phone = ""; try { JSONObject jsonObject = new JSONObject(response); JSONArray result = jsonObject.getJSONArray("Nek"); JSONObject collegeData = result.getJSONObject(0); id = collegeData.getString("ID"); name = collegeData.getString("NekName"); adress1 = collegeData.getString("NekAdress2"); adress2 = collegeData.getString("NekAdress2"); phone = collegeData.getString("NekPhone"); AtomicInteger id2 = new AtomicInteger(); /* if (id == null || id == "" || id == " "){ addInfo(Phone); }*/ //else { Book book = new Book(); book.setId(id2.getAndIncrement()); book.setNekID(id); book.setName(name); book.setPhone(phone); book.setAdress1(adress1); book.setAdress2(adress2); book.setStatus(1); Intent dialogIntent = new Intent(getBaseContext(), MainActivity.class); /* dialogIntent.putExtra("Name", name); dialogIntent.putExtra("Phone", phone); dialogIntent.putExtra("Adress1", adress1); dialogIntent.putExtra("Adress2", adress2); dialogIntent.putExtra("NekID", id); */ dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplication().startActivity(dialogIntent); // } } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.msdpe.authenticationdemo.AuthService.java
/** * Handles logging the user out including: * -deleting cookies so their login with a provider won't be cached in the web view * -removing the userdata from the shared preferences * -setting the current user object on the client to logged out * -optionally redirects to the login page if requested * @param shouldRedirectToLogin//from w ww . j a v a 2s. c o m */ public void logout(boolean shouldRedirectToLogin) { //Clear the cookies so they won't auto login to a provider again CookieSyncManager.createInstance(mContext); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); //Clear the user id and token from the shared preferences SharedPreferences settings = mContext.getSharedPreferences("UserData", 0); SharedPreferences.Editor preferencesEditor = settings.edit(); preferencesEditor.clear(); preferencesEditor.commit(); //Clear the user and return to the auth activity mClient.logout(); //Take the user back to the auth activity to relogin if requested if (shouldRedirectToLogin) { Intent logoutIntent = new Intent(mContext, AuthenticationActivity.class); logoutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(logoutIntent); } }
From source file:mobisocial.musubi.objects.PictureObj.java
@Override public void activate(Context context, DbObj obj) { // TODO: set data uri for obj Intent intent = new Intent(context, ImageGalleryActivity.class); intent.setData(obj.getContainingFeed().getUri()); intent.putExtra(ImageGalleryActivity.EXTRA_DEFAULT_OBJECT_ID, obj.getLocalId()); if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }/* www . j a v a 2s . c o m*/ context.startActivity(intent); }
From source file:com.mobiperf.AccountSelector.java
private void getAuthToken(AccountManagerFuture<Bundle> result) { Logger.i("getAuthToken() called, result " + result); String errMsg = "Failed to get login cookie. "; Bundle bundle;/* w ww . ja v a 2 s . c o m*/ try { bundle = result.getResult(); Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT); if (intent != null) { // User input required. (A UI will pop up for user's consent to allow // this app access account information.) Logger.i("Starting account manager activity"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else { Logger.i("Executing getCookie task"); synchronized (this) { this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); this.checkinFuture = checkinExecutor.submit(new GetCookieTask()); } } } catch (OperationCanceledException e) { Logger.e(errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (AuthenticatorException e) { Logger.e(errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (IOException e) { Logger.e(errMsg, e); throw new RuntimeException("Can't get login cookie", e); } }
From source file:com.mobage.android.shellappsdk.sample.GameWebView.java
private boolean handleExternalDomainUrl(String url) { Uri uri = Uri.parse(url);// ww w. j a v a2s . c o m String host = uri.getHost(); if (mDomainWhiteList.containsHost(host)) { return false; } // No match - Sending Intent to External Browser if ("http".equalsIgnoreCase(uri.getScheme()) || "https".equalsIgnoreCase(uri.getScheme())) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (getContext() instanceof Activity) { getContext().startActivity(intent); } } return true; }
From source file:com.num.mobiperf.AccountSelector.java
private void getAuthToken(AccountManagerFuture<Bundle> result) { //Logger.i("getAuthToken() called, result " + result); String errMsg = "Failed to get login cookie. "; Bundle bundle;//from w w w . j a v a 2s.co m try { bundle = result.getResult(); Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT); if (intent != null) { // User input required. (A UI will pop up for user's consent to allow // this app access account information.) //Logger.i("Starting account manager activity"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else { //Logger.i("Executing getCookie task"); synchronized (this) { this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); this.checkinFuture = checkinExecutor.submit(new GetCookieTask()); } } } catch (OperationCanceledException e) { //Logger.e(errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (AuthenticatorException e) { //Logger.e(errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (IOException e) { //Logger.e(errMsg, e); throw new RuntimeException("Can't get login cookie", e); } }
From source file:com.orange.labs.sdk.session.AuthSession.java
/** * Start authentication. If needed, launch {@code AuthActivity} * allowing an user authentication else wait to check authentication with refresh token * {@link #checkAuthentication(com.orange.labs.sdk.OrangeListener.Success, * com.orange.labs.sdk.OrangeListener.Error)} *///from w ww. ja v a 2 s .com public void startAuthentication() { String refreshToken = getRefreshToken(); // If refresh token exists, connect directly else // show web authent inside AuthActivity if (refreshToken == null || refreshToken.length() == 0) { // Start Orange auth activity. Intent intent = new Intent(context, AuthActivity.class); // Check if Oauth has to force user to enter login & password SharedPreferences sharedPref = context.getApplicationContext() .getSharedPreferences(SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE); boolean forceLogin = sharedPref.getBoolean(SHARED_PREFERENCES_FORCE_LOGIN, false); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_FORCE_LOGIN, forceLogin); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_KEY, getAppkey()); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_SCOPE, getScope()); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_REDIRECT_URI, getRedirectUri()); if (!(context instanceof Activity)) { // If starting the intent outside of an Activity, must include // this. See startActivity(). Otherwise, we prefer to stay in // the same task. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } context.startActivity(intent); } }
From source file:com.frostwire.android.gui.util.UIUtils.java
/** * Opens the given file with the default Android activity for that File and * mime type.//w w w . j ava 2 s .c o m */ public static void openFile(Context context, String filePath, String mime, boolean useFileProvider) { try { if (filePath != null && !openAudioInternal(context, filePath)) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(getFileUri(context, filePath, useFileProvider), Intent.normalizeMimeType(mime)); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION); if (mime != null && mime.contains("video")) { if (MusicUtils.isPlaying()) { MusicUtils.playOrPause(); } UXStats.instance().log(UXAction.LIBRARY_VIDEO_PLAY); } context.startActivity(i); } } catch (Throwable e) { UIUtils.showShortMessage(context, R.string.cant_open_file); LOG.error("Failed to open file: " + filePath, e); } }