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.mobilyzer.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 . ja 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); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_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.microsoft.firstapp.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 * /* w w w .ja v a2 s .c o m*/ * @param shouldRedirectToLogin */ 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, LogInActivity.class); logoutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(logoutIntent); } }
From source file:cn.whereyougo.framework.utils.PackageManagerUtil.java
/** * ????/* ww w. j a v a 2 s . co m*/ * * @param mContext * * @param TagClass * ??? * @param iconResId * ?? * @param iconName * ?? */ public static void addShortCut2Desktop(Context mContext, Class<?> TagClass, int iconResId, String iconName) { SharedPreferences sp = mContext.getSharedPreferences("appinfo", Context.MODE_PRIVATE); if (!sp.getBoolean("shortcut_flag_icon", false)) { sp.edit().putBoolean("shortcut_flag_icon", true).commit(); LogUtil.d("shortcut", "first create successfull"); } else { LogUtil.d("shortcut", "no created"); return; } String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; Intent intent = new Intent(); intent.setClass(mContext, TagClass); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT); Parcelable icon = Intent.ShortcutIconResource.fromContext(mContext, iconResId);// ??? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, iconName);// ?? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);// ?? addShortcut.putExtra("duplicate", false);// ???? addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);// ?? mContext.sendBroadcast(addShortcut);// ?? }
From source file:de.unclenet.dehabewe.CalendarActivity.java
private void gotAccount(final AccountManager manager, final Account account) { SharedPreferences settings = getSharedPreferences(PREF, 0); SharedPreferences.Editor editor = settings.edit(); editor.putString("accountName", account.name); editor.commit();//from ww w .j a v a 2s. c o m new Thread() { @Override public void run() { try { final Bundle bundle = manager.getAuthToken(account, AUTH_TOKEN_TYPE, true, null, null) .getResult(); runOnUiThread(new Runnable() { public void run() { try { if (bundle.containsKey(AccountManager.KEY_INTENT)) { Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT); int flags = intent.getFlags(); flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK; intent.setFlags(flags); startActivityForResult(intent, REQUEST_AUTHENTICATE); } else if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) { authenticatedClientLogin(bundle.getString(AccountManager.KEY_AUTHTOKEN)); } } catch (Exception e) { handleException(e); } } }); } catch (Exception e) { handleException(e); } } }.start(); }
From source file:cn.com.incardata.autobon_shops.CooperativeThreeActivity.java
public void showTipsDialog() { final CheckTipsDialog dialog = new CheckTipsDialog(this, R.style.TipsDialog); dialog.setOnPositiveListener(new View.OnClickListener() { @Override/*from www .ja va 2s . com*/ public void onClick(View view) { dialog.dismiss(); //TODO ? } }); dialog.show(); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { Intent intent = new Intent(getContext(), LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); } }); }
From source file:com.orange.oidc.secproxy_service.HttpOpenidConnect.java
public boolean getTokens(Context ctx, String id, String login) { if (mOcp == null) return false; try {//from w w w . j a v a 2s. co m String requestObject = null; String authorization_endpoint = null; try { // retrieve openid config JSONObject json = getHttpJSON(mOcp.m_server_url + openIdConfigurationUrl); if (json == null) { Logd(TAG, "could not get openid-configuration on server : " + mOcp.m_server_url); return false; } // get authorization end_point authorization_endpoint = json.optString("authorization_endpoint"); Logd(TAG, "authorization_endpoint : " + authorization_endpoint); // TAZTAG : no use to define request object if key jwt is not used ? if (mUsePrivateKeyJWT) { // get jwks_uri of the server String jwks_uri = json.optString("jwks_uri"); if (jwks_uri == null || jwks_uri.length() < 1) { Logd(TAG, "could not get jwks_uri from openid-configuration on server : " + mOcp.m_server_url); return false; } Logd(TAG, "jwks_uri : " + jwks_uri); // get jwks String jwks = getHttpString(jwks_uri); if (jwks == null || jwks.length() < 1) { Logd(TAG, "could not get jwks_uri content from : " + jwks_uri); return false; } Logd(TAG, "jwks : " + jwks); // extract public key PublicKey serverPubKey = KryptoUtils.pubKeyFromJwk(jwks); if (serverPubKey == null) { Logd(TAG, "could not extract public key from jwk : " + jwks); return false; } // get oidc request object requestObject = secureProxy.getOidcRequestObject(mOcp.m_server_url, mOcp.m_client_id, mOcp.m_scope, serverPubKey); Logd(TAG, "secureStorage requestObject : " + requestObject); } } catch (Exception ee) { // error generating request object ee.printStackTrace(); return false; } // build post parameters List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7); nameValuePairs.add(new BasicNameValuePair("redirect_uri", mOcp.m_redirect_uri)); nameValuePairs.add(new BasicNameValuePair("response_type", "code")); nameValuePairs.add(new BasicNameValuePair("scope", mOcp.m_scope)); nameValuePairs.add(new BasicNameValuePair("client_id", secureProxy.getClientId())); // nameValuePairs.add(new BasicNameValuePair("nonce", mOcp.m_nonce)); nameValuePairs.add(new BasicNameValuePair("nonce", "1234567890")); if (!isEmpty(requestObject)) { nameValuePairs.add(new BasicNameValuePair("request", requestObject)); } nameValuePairs.add(new BasicNameValuePair("prompt", "consent")); // get URL encoded string from list of key value pairs String postParams = getQuery(nameValuePairs); Log.d(TAG, "get URL encoded string from list of key value pairs : " + postParams); // launch webview // init intent Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(ctx, WebViewActivity.class); // prepare request parameters intent.putExtra("id", id); intent.putExtra("server_url", authorization_endpoint); intent.putExtra("redirect_uri", mOcp.m_redirect_uri); intent.putExtra("client_id", mOcp.m_client_id); if (login != null) intent.putExtra("login", login); intent.putExtra("postParams", postParams); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION); // display webview ctx.startActivity(intent); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:com.orange.oidc.tim.service.HttpOpenidConnect.java
public boolean getTokens(Context ctx, String id, boolean useTim, String login) { if (mOcp == null) return false; try {//from ww w . j a v a 2 s . c o m String requestObject = null; String authorization_endpoint = null; try { // retrieve openid config JSONObject json = getHttpJSON(mOcp.m_server_url + openIdConfigurationUrl); if (json == null) { Logd(TAG, "could not get openid-configuration on server : " + mOcp.m_server_url); return false; } // get authorization end_point authorization_endpoint = json.optString("authorization_endpoint"); if (useTim) { // get jwks_uri of the server String jwks_uri = json.optString("jwks_uri"); if (jwks_uri == null || jwks_uri.length() < 1) { Logd(TAG, "could not get jwks_uri from openid-configuration on server : " + mOcp.m_server_url); return false; } // get jwks String jwks = getHttpString(jwks_uri); if (jwks == null || jwks.length() < 1) { Logd(TAG, "could not get jwks_uri content from : " + jwks_uri); return false; } // extract public key PublicKey serverPubKey = KryptoUtils.pubKeyFromJwk(jwks); if (serverPubKey == null) { Logd(TAG, "could not extract public key from jwk : " + jwks); return false; } // get tim request object requestObject = secureStorage.getTimRequestObject(mOcp.m_server_url, mOcp.m_client_id, mOcp.m_scope, serverPubKey); Logd(TAG, "secureStorage requestObject : " + requestObject); } } catch (Exception ee) { // error generating request object ee.printStackTrace(); return false; } // build post parameters List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7); nameValuePairs.add(new BasicNameValuePair("redirect_uri", mOcp.m_redirect_uri)); nameValuePairs.add(new BasicNameValuePair("response_type", "code")); nameValuePairs.add(new BasicNameValuePair("scope", mOcp.m_scope)); if (useTim) nameValuePairs.add(new BasicNameValuePair("client_id", secureStorage.getClientId())); else nameValuePairs.add(new BasicNameValuePair("client_id", mOcp.m_client_id)); nameValuePairs.add(new BasicNameValuePair("nonce", mOcp.m_nonce)); if (!isEmpty(requestObject)) { nameValuePairs.add(new BasicNameValuePair("request", requestObject)); } nameValuePairs.add(new BasicNameValuePair("prompt", "consent")); // get URL encoded string from list of key value pairs String postParams = getQuery(nameValuePairs); // launch webview // init intent Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(ctx, WebViewActivity.class); // prepare request parameters intent.putExtra("id", id); intent.putExtra("server_url", authorization_endpoint); intent.putExtra("redirect_uri", mOcp.m_redirect_uri); intent.putExtra("client_id", mOcp.m_client_id); if (login != null) intent.putExtra("login", login); if (useTim) { intent.putExtra("use_tim", true); } else { intent.putExtra("client_secret", mOcp.m_client_secret); } intent.putExtra("postParams", postParams); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION); // display webview ctx.startActivity(intent); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:com.adguard.android.commons.BrowserUtils.java
public static void startBrowser(Context context, ComponentName component) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(component);/*w w w .ja v a 2s. c om*/ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:com.procasy.dubarah_nocker.gcm.MyGcmPushReceiver.java
/** * Called when message is received./*from w ww . j av a2 s .c o m*/ * * @param from SenderID of the sender. * @param bundle Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ @Override public void onMessageReceived(String from, Bundle bundle) { MainActivity.getInstance().updateNotification(); try { Log.e("notify_gcm", "success , type = " + bundle.toString()); switch (bundle.getString(GCM_TAG)) { case "GENERAL": { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG)) .setContentText(bundle.getString(DESC_TAG)); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(12, mBuilder.build()); mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext()); mNotification.open(); try { ContentValues contentValues = new ContentValues(); contentValues.put(mNotification.COL_notification_type, GENERAL_TAG); contentValues.put(mNotification.COL_notfication_status, 0); contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG)); contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG)); contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG)); mNotification.insertEntry(contentValues); } catch (Exception e) { e.printStackTrace(); } finally { mNotification.close(); } break; } case "HELP": { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG)) .setContentText(bundle.getString(DESC_TAG)); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(12, mBuilder.build()); mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext()); mNotification.open(); try { ContentValues contentValues = new ContentValues(); contentValues.put(mNotification.COL_notification_type, HELP_TAG); contentValues.put(mNotification.COL_notfication_status, 0); contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG)); contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG)); contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG)); mNotification.insertEntry(contentValues); } catch (Exception e) { e.printStackTrace(); } finally { mNotification.close(); } JSONObject content = new JSONObject(bundle.getString("content")); JSONObject hr = content.getJSONObject("hr"); JSONArray album = content.getJSONArray("album"); System.out.println(content.getInt("hr_id")); System.out.println(content.toString()); Bundle bundle1 = new Bundle(); bundle1.putString("hr_id", hr.getString("hr_id")); bundle1.putString("hr_user_id", hr.getString("hr_user_id")); bundle1.putString("hr_description", hr.getString("hr_description")); bundle1.putString("hr_est_date", hr.getString("hr_est_date")); bundle1.putString("hr_est_time", hr.getString("hr_est_time")); bundle1.putString("hr_skill_id", hr.getString("hr_skill_id")); bundle1.putString("hr_ua_id", hr.getString("hr_ua_id")); bundle1.putString("hr_voice_record", hr.getString("hr_voice_record")); bundle1.putString("hr_language", hr.getString("hr_language")); bundle1.putString("hr_lat", hr.getString("hr_lat")); bundle1.putString("hr_lon", hr.getString("hr_lon")); bundle1.putString("hr_address", hr.getString("hr_address")); ArrayList<String> array = new ArrayList<>(); for (int i = 0; i < album.length(); i++) { JSONObject object = album.getJSONObject(i); array.add(object.getString("ahr_img")); } bundle1.putStringArrayList("album", array); Intent intent = (new Intent(getApplicationContext(), JobRequestActivity.class)); intent.putExtras(bundle1); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(intent); break; } case "APPOINTEMENT": { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG)) .setContentText(bundle.getString(DESC_TAG)); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(12, mBuilder.build()); mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext()); mNotification.open(); try { ContentValues contentValues = new ContentValues(); contentValues.put(mNotification.COL_notification_type, APPOINTEMENT_TAG); contentValues.put(mNotification.COL_notfication_status, 0); contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG)); contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG)); contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG)); mNotification.insertEntry(contentValues); } catch (Exception e) { e.printStackTrace(); } finally { mNotification.close(); } break; } case "QOUTA_USER": { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG)) .setContentText(bundle.getString(DESC_TAG)); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(12, mBuilder.build()); mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext()); mNotification.open(); try { ContentValues contentValues = new ContentValues(); contentValues.put(mNotification.COL_notification_type, USER_Qouta_TAG); contentValues.put(mNotification.COL_notfication_status, 0); contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG)); contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG)); contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG)); mNotification.insertEntry(contentValues); } catch (Exception e) { e.printStackTrace(); } finally { mNotification.close(); } break; } case "QOUTA_NOCKER": { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.hourly_logo).setContentTitle(bundle.getString(TITLE_TAG)) .setContentText(bundle.getString(DESC_TAG)); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(12, mBuilder.build()); mNotification = new com.procasy.dubarah_nocker.Helper.Notification(getApplicationContext()); mNotification.open(); try { ContentValues contentValues = new ContentValues(); contentValues.put(mNotification.COL_notification_type, Nocker_Qouta_TAG); contentValues.put(mNotification.COL_notfication_status, 0); contentValues.put(mNotification.COL_notfication_title, bundle.getString(TITLE_TAG)); contentValues.put(mNotification.COL_notfication_desc, bundle.getString(DESC_TAG)); contentValues.put(mNotification.COL_notfication_content, bundle.getString(CONTENT_TAG)); mNotification.insertEntry(contentValues); } catch (Exception e) { e.printStackTrace(); } finally { mNotification.close(); } break; } } } catch (Exception e) { e.printStackTrace(); } }