List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TASK
int FLAG_ACTIVITY_CLEAR_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_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;// ww w . ja va 2s . 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); 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.example.team04adventure.Controller.OnlineStoryList.java
/** * Starts a dialog box which allows the user to create a new story. * /* ww w.j av a2s. c o m*/ * @param view * the current view. */ public void addStory(View view) { AlertDialog.Builder adb = new AlertDialog.Builder(this); LinearLayout lila1 = new LinearLayout(this); lila1.setOrientation(1); final EditText titleinput = new EditText(this); final EditText bodyinput = new EditText(this); titleinput.setHint("Enter the Title here."); bodyinput.setHint("Enter a Synopsis here."); lila1.addView(titleinput); lila1.addView(bodyinput); adb.setView(lila1); adb.setTitle("New Story"); adb.setNegativeButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Story story = new Story(); story.setTitle(titleinput.getText().toString()); Random rg = new Random(); int rint = rg.nextInt(100); story.setSynopsis(bodyinput.getText().toString()); story.setId(story.getTitle().replace(" ", "") + rint); story.setAuthor(MainActivity.username); story.setVersion(1); StorageManager sm = new StorageManager(getBaseContext()); sm.addStory(story); Intent intent = new Intent(OnlineStoryList.this, OnlineStoryList.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); adb.setPositiveButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); adb.show(); }
From source file:com.nononsenseapps.feeder.ui.BaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from w w w. j av a2s . c o m switch (id) { case android.R.id.home: if (mShouldFinishBack) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAfterTransition(); } else { finish(); } } else { Intent intent = new Intent(this, FeedActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.xconns.peerdevicenet.core.CoreAPI.java
@TargetApi(5) @Override//from ww w.j a v a 2 s .c om public void onCreate() { // TODO Auto-generated method stub super.onCreate(); Log.d(TAG, "RouterService onCreate()"); timer = new ScheduledThreadPoolExecutor(1); linkMgr = new TransportManager(this, linkHandler); linkMgr.onResume(); mMyDeviceInfo = new DeviceInfo(); //loc wifi myWifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "mywifilock"); myWifiLock.acquire(); // init tcp connector mTCPConn = new TCPConnector(this); // notify others router is up by send ACTION_ROUTER_UP // eg. start remote intent service here Intent startupSignal = new Intent(Router.Intent.ACTION_ROUTER_UP); startService(startupSignal); // add notification and start service at foreground /*Notification notification = new Notification(R.drawable.router_icon, getText(R.string.router_notif_ticker), System.currentTimeMillis());*/ // Instantiate a Builder object. NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(getText(R.string.router_notif_title)) .setTicker(getText(R.string.router_notif_ticker)) .setContentText(getText(R.string.router_notif_message)).setSmallIcon(R.drawable.router_icon); // Intent notificationIntent = new Intent(Router.Intent.ACTION_CONNECTOR); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(pendingIntent); // using id of ticker text as notif id startForeground(R.string.router_notif_ticker, builder.build()); }
From source file:cz.maresmar.sfm.view.MainActivity.java
/** * Returns {@link PendingIntent} that can start this activity with open {@link Drawer} * * @param context Some valid context/*from w w w.j a v a 2 s . c o m*/ * @return PendingIntent that starts activity */ public static PendingIntent getShowCreditIntent(Context context) { Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.setAction(SHOW_CREDIT_ACTION); return PendingIntent.getActivity(context, 0, intent, 0); }
From source file:com.android.prachat.gcm.MyGcmPushReceiver.java
/** * Showing notification with text only/* www . j a v a 2s.c om*/ * */ private void showNotificationMessage(Context context, String title, String message, String timeStamp, Intent intent) { notificationUtils = new NotificationUtils(context); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); notificationUtils.showNotificationMessage(title, message, timeStamp, intent); }
From source file:com.zaparound.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from w w w . java 2 s . c o m private void sendNotificationZapRequest(String messagetitle, String messageBody) { Intent intent = new Intent(this, LandingActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("CHECKIN_TAB_POS", 1); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); Notification notification = mBuilder.setSmallIcon(R.drawable.applogo).setTicker(messagetitle).setWhen(0) .setAutoCancel(true).setContentTitle(messagetitle) //.setNumber(++count) .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody)) //.setSubText("\n "+count+" new messages\n") .setContentIntent(pendingIntent) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.applogo)) .setContentText(messageBody).build(); NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notification); }
From source file:com.artemchep.horario.ui.fragments.AuthFragment.java
private void switchToMainActivity() { Intent intent = new Intent(getContext(), MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);/*from www .jav a2 s . co m*/ }
From source file:com.friedran.appengine.dashboard.gui.DashboardActivity.java
private void logout() { new DashboardPreferences(this).resetSavedAccount(); Intent intent = new Intent(this, LoginActivity.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);/*from www . java 2 s . co m*/ }
From source file:it.uniroma2.foundme.studente.Connection.java
@Override protected void onPostExecute(String result[]) { if (result[0].equalsIgnoreCase(Variables_it.NO_INTERNET)) { if (enProgressDialog) caricamento.dismiss();/*from w w w .ja v a 2s . c om*/ Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show(); return; } if (enProgressDialog) { caricamento.dismiss(); if (!returnMessage.equalsIgnoreCase(Variables_it.NAME) || result[0].equalsIgnoreCase(Variables_it.ERROR)) { if (!returnMessage.equalsIgnoreCase(Variables_it.SHOW) && !returnMessage.equalsIgnoreCase(Variables_it.FOLLOW) && !returnMessage.equalsIgnoreCase(Variables_it.UNFOLLOW) && !returnMessage.equalsIgnoreCase(Variables_it.MSG) && !returnMessage.equalsIgnoreCase(Variables_it.MID)) { Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show(); } } } if (toDo.equalsIgnoreCase(Variables_it.GET)) { if (returnMessage.equalsIgnoreCase(Variables_it.SHOW)) ShowCourseActivity.populateView(result); if (returnMessage.equalsIgnoreCase(Variables_it.FOLLOW)) FollowCourseActivity.populateView(result); if (returnMessage.equalsIgnoreCase(Variables_it.UNFOLLOW)) UnFollowCourseActivity.populateView(result); if (returnMessage.equalsIgnoreCase(Variables_it.MSG)) ReadMessageActivity.populateView(result); if (returnMessage.equalsIgnoreCase(Variables_it.MID)) ShowMsgActivity.populateView(result); } else if (returnMessage.equalsIgnoreCase(Variables_it.NAME) && toDo.equalsIgnoreCase(Variables_it.LOG) && !result[0].equalsIgnoreCase(Variables_it.ERROR)) { SharedPreferences pref = SPEditor.init(context); SPEditor.setUser(pref, LoginActivity.getuser()); SPEditor.setPass(pref, LoginActivity.getpass()); SPEditor.setGCM(pref, result[2]); SPEditor.setID(pref, result[1]); Intent intent = new Intent(context, HomeActivity.class); intent.putExtra(Variables_it.NAME, result[0]); intent.putExtra(Variables_it.ID, result[1]); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); context.startActivity(intent); } else if (toDo.equalsIgnoreCase(Variables_it.INFOC)) { try { CourseActivity.setFields(json_data.getString(Variables_it.CFU), json_data.getString(Variables_it.NAME_1), json_data.getString(Variables_it.NAME_2), json_data.getInt(Variables_it.NOTIFICATION)); } catch (JSONException e) { e.printStackTrace(); } } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.CHANGEP)) { SharedPreferences pref = SPEditor.init(context); SPEditor.setPass(pref, ChangePswActivity.getpass()); ((Activity) context).finish(); } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.REGIS)) { SharedPreferences pref = SPEditor.init(context); SPEditor.setUser(pref, RegistrationActivity.getmail()); SPEditor.setPass(pref, RegistrationActivity.getpass()); ((Activity) context).finish(); } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.DELACC)) { SharedPreferences pref = SPEditor.init(context); SPEditor.delete(pref); Intent intent = new Intent(context, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); context.startActivity(intent); } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.UNFOLLOW)) { try { UnFollowCourseActivity.getCourse(true); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }