List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:com.streaming.sweetplayer.PlayerActivity.java
private Intent getDefaultIntent() { String urlToShare = Config.DOMAIN + sSongUrl; String sharingText = mActivity.getString(R.string.sharing_text) + " " + urlToShare + " " + mActivity.getString(R.string.sharing_android_app) + " " + Config.GOOGLE_PLAY_LINK; Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, sSongName); sharingIntent.putExtra(Intent.EXTRA_TEXT, sharingText); return sharingIntent; }
From source file:com.google.wireless.speed.speedometer.AccountSelector.java
private void getAuthToken(AccountManagerFuture<Bundle> result) { Log.i(SpeedometerApp.TAG, "getAuthToken() called, result " + result); String errMsg = "Failed to get login cookie. "; Bundle bundle;/*ww w. j a v a 2 s. c om*/ 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.) Log.i(SpeedometerApp.TAG, "Starting account manager activity"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else { Log.i(SpeedometerApp.TAG, "Executing getCookie task"); synchronized (this) { this.authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN); this.checkinFuture = checkinExecutor.submit(new GetCookieTask()); } } } catch (OperationCanceledException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (AuthenticatorException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } catch (IOException e) { Log.e(SpeedometerApp.TAG, errMsg, e); throw new RuntimeException("Can't get login cookie", e); } }
From source file:com.qbcps.sifterclient.SifterReader.java
/** start LoginActivity to get domain and access key. */ private void loginKeys(Integer flags) { Intent intent = new Intent(this, LoginActivity.class); if (flags != null) { intent.addFlags(flags); }// ww w . java 2s. c om intent.putExtra(DOMAIN, mDomain); intent.putExtra(ACCESS_KEY, mAccessKey); intent.putExtra(LOGIN_ERROR, mLoginError.toString()); startActivityForResult(intent, ACTIVITY_LOGIN); }
From source file:com.snappy.GCMIntentService.java
@SuppressWarnings("deprecation") public void triggerNotification(Context context, String message, String fromName, Bundle pushExtras, String messageData) {/* ww w .j a va 2s.c om*/ if (fromName != null) { final NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon_notification, message, System.currentTimeMillis()); notification.number = mNotificationCounter + 1; mNotificationCounter = mNotificationCounter + 1; Intent intent = new Intent(this, SplashScreenActivity.class); intent.replaceExtras(pushExtras); intent.putExtra(Const.PUSH_INTENT, true); intent.setAction(Long.toString(System.currentTimeMillis())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_TASK_ON_HOME); PendingIntent pendingIntent = PendingIntent.getActivity(this, notification.number, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(this, context.getString(R.string.app_name), messageData, pendingIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_VIBRATE; notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_LIGHTS; String notificationId = Double.toString(Math.random()); notificationManager.notify(notificationId, 0, notification); } Log.i(LOG_TAG, message); Log.i(LOG_TAG, fromName); }
From source file:com.xpple.jahoqy.BaseClass.DemoHXSDKHelper.java
@Override protected void onConnectionConflict() { Intent intent = new Intent(appContext, IndexFragment.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("conflict", true); appContext.startActivity(intent);/*w w w .ja v a2 s. c o m*/ }
From source file:com.xpple.jahoqy.BaseClass.DemoHXSDKHelper.java
@Override protected void onCurrentAccountRemoved() { Intent intent = new Intent(appContext, IndexFragment.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Constant.ACCOUNT_REMOVED, true); appContext.startActivity(intent);//from w ww . j a v a 2 s. com }
From source file:cn.hbm.superwechat.DemoHXSDKHelper.java
@Override protected void onCurrentAccountRemoved() { Intent intent = new Intent(appContext, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(cn.hbm.superwechat.Constant.ACCOUNT_REMOVED, true); appContext.startActivity(intent);//from w ww . j a va 2s . c o m }
From source file:com.parse.CN1ParsePushBroadcastReceiver.java
@Override protected void onPushOpen(Context context, Intent intent) { /*// ww w.ja v a 2 s. c o m Adapted from ParsePushBroadcastReceiver. Main changes: 1. Adapted code for starting app activity since it caused problems (see comments towards the end of the method starting from line 'Original code' 2. Implemented necessary ParsePush callback to set push data in advance so that it will be available when the app activity is started/resumed */ // Send a Parse Analytics "push opened" event ParseAnalytics.trackAppOpenedInBackground(intent); JSONObject pushData = null; String uriString = null; try { pushData = new JSONObject(intent.getStringExtra(ParsePushBroadcastReceiver.KEY_PUSH_DATA)); uriString = pushData.optString("uri", null); } catch (JSONException e) { writeErrorLog("Unexpected JSONException when parsing " + "push data from opened notification: " + e); } writeDebugLog("Push opened: " + (pushData == null ? "<no payload>" : pushData.toString())); if (pushData != null) { // Forward payload so that it is available when app is opened via the push message ParsePush.handlePushOpen(pushData.toString(), CN1AndroidApplication.isAppInForeground()); writeDebugLog("Notified ParsePush of opened push notification"); } Class<? extends Activity> cls = getActivity(context, intent); Intent activityIntent; if (uriString != null) { writeDebugLog("Creating an intent to view URI: " + uriString); activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString)); } else { activityIntent = new Intent(context, cls); } activityIntent.putExtras(intent.getExtras()); activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Original code // /* // In order to remove dependency on android-support-library-v4 // The reason why we differentiate between versions instead of just using context.startActivity // for all devices is because in API 11 the recommended conventions for app navigation using // the back key changed. // */ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // TaskStackBuilderHelper.startActivities(context, cls, activityIntent); // } else { // context.startActivity(activityIntent); // } // The task stack builder approach causes only the title and a white (blank) screen // to be shown when the app is in the foreground and the push notification is // opened (see also problem report to CN1 support forum: https://groups.google.com/d/msg/codenameone-discussions/Z3F924j_BG4/7rn7v7oABwAJ) // As a result, the context.startActivity() approach is currently taken always. // Not sure yet if it has any undesirable side effects for sdk version // before JELLY_BEAN (actually HONEYCOMB (v3.0) according to TaskStackBuilder documentation // at: http://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.html. context.startActivity(activityIntent); }
From source file:org.safegees.safegees.gui.view.MainActivity.java
public void setNoInternetAdvice(Context context) { final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(getResources().getString(R.string.splash_advice_first_use_advice)).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i);/*from w w w. j a va 2s . co m*/ //finish(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.ferasinfotech.gwreader.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View.OnLongClickListener click_listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { Intent i = new Intent(Intent.ACTION_VIEW); String s = "https://www.grasswire.com"; if (mStoryID != 0) { s = s + "/story/" + mStoryID + "/x"; }// w w w .j ava 2 s . com i.setData(Uri.parse(s)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); return true; } }; ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false); // Picasso.with(getActivity()).setLoggingEnabled(true); // Picasso.with(getActivity()).setIndicatorsEnabled(true); ImageView cover_image = (ImageView) rootView.findViewById(R.id.story_image); Picasso.with(getActivity()).load(mCoverPhoto).into(cover_image); cover_image.setOnLongClickListener(click_listener); ((TextView) rootView.findViewById(R.id.story_title)).setText(mTitle); ((TextView) rootView.findViewById(R.id.story_headline)).setText(mHeadline); ((TextView) rootView.findViewById(R.id.story_summary)).setText(mSummary); Log.d("***DEBUG***", "Building page:" + mPageNumber); if (mStoryID != 0) { LinksAdapter adapter = new LinksAdapter(getActivity(), mStoryString); LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.story_layout); for (int i = 0; i < adapter.getCount(); i++) { View listItem = adapter.getView(i, null, ll); ll.addView(listItem); } } return rootView; }