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.rampgreen.caretakermobile.GcmIntentService.java
private void sendNotification(String notificationTitle, String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Bundle bundle = new Bundle(); bundle.putString(Constants.NOTIFICATION_MSG, msg); bundle.putString(Constants.CALLED_COMPONENT, Constants.SERVICE_GCM_INTENT); Intent notificationIntent = new Intent(this, ActivityNotification.class); notificationIntent.putExtras(bundle); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(notificationTitle) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(contentIntent); Notification notification = mBuilder.build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify(NOTIFICATION_ID, notification); }
From source file:com.android.contacts.activities.ContactDetailActivity.java
/** @} */ @Override/* w w w . java 2 s. c om*/ protected void onCreate(Bundle savedState) { super.onCreate(savedState); LogUtils.i(TAG, "[onCreate][launch]start"); ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet registerPHBReceiver(); mIsActivitFinished = false; /** M: Bug Fix for ALPS00393950 @{ */ boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this); if (!isUsingTwoPanes) { SetIndicatorUtils.getInstance().registerReceiver(this); } /** @} */ if (PhoneCapabilityTester.isUsingTwoPanes(this)) { // This activity must not be shown. We have to select the contact in the // PeopleActivity instead ==> Create a forward intent and finish final Intent originalIntent = getIntent(); Intent intent = new Intent(); intent.setAction(originalIntent.getAction()); intent.setDataAndType(originalIntent.getData(), originalIntent.getType()); // If we are launched from the outside, we should create a new task, because the user // can freely navigate the app (this is different from phones, where only the UP button // kicks the user into the full app) if (shouldUpRecreateTask(intent)) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); } else { intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); } intent.setClass(this, PeopleActivity.class); startActivity(intent); LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity.."); finish(); return; } setContentView(R.layout.contact_detail_activity); mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(), null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener); // We want the UP affordance but no app icon. // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick. ActionBar actionBar = getActionBar(); if (actionBar != null) { ///@Modify for add Customer view{ actionBar.setDisplayOptions( ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM); ///@} actionBar.setTitle(""); } Log.i(TAG, getIntent().getData().toString()); /** M: New Feature xxx @{ */ //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE if (getIntent() != null && getIntent().getData() != null) { mSimOrPhoneUri = getIntent().getData(); Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri); } else { Log.e(TAG, "Get intent data error getIntent() = " + getIntent()); } /// M: @ CT contacts detail history set listener{ ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(), ContactPluginDefault.COMMD_FOR_OP09); /// @} LogUtils.i(TAG, "[onCreate][launch]end"); }
From source file:com.supremainc.biostar2.push.GcmBroadcastReceiver.java
private PendingIntent getPendingIntent(Context context, Class<?> cls) { Intent notificationIntent = null;//w w w. j ava 2 s. c o m notificationIntent = new Intent(context, cls); notificationIntent .setAction(Setting.ACTION_NOTIFICATION_START + String.valueOf(System.currentTimeMillis())); if (!Setting.IS_NOTIFICATION_NONE_RESTART) { notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); } PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); return pendingIntent; }
From source file:com.enadein.carlogbook.db.CommonUtils.java
public static void createNotify(Context ctx, long id, int res) { Cursor c = ctx.getContentResolver().query(ProviderDescriptor.Notify.CONTENT_URI, null, BaseActivity.SELECTION_ID_FILTER, new String[] { String.valueOf(id) }, null); UnitFacade notifyUF = new UnitFacade(ctx); boolean vibrate = "1".equals(notifyUF.getSetting(UnitFacade.SET_NOTIFY_VIBRATE, "1")); boolean sound = "1".equals(notifyUF.getSetting(UnitFacade.SET_NOTIFY_SOUND, "1")); if (c == null) { return;//w ww.j av a2 s . com } boolean hasItem = c.moveToFirst(); if (!hasItem) { return; } int nameIdx = c.getColumnIndex(ProviderDescriptor.Notify.Cols.NAME); String name = c.getString(nameIdx); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx).setSmallIcon(res); if (sound) { mBuilder.setSound(alarmSound); } // if (vibrate) { // mBuilder.setVibrate(new long[] {1000, 500, 1000}); // } mBuilder.setContentTitle(ctx.getString(R.string.app_name)).setContentText(name); NotificationManager mNotificationManager = (NotificationManager) ctx .getSystemService(Context.NOTIFICATION_SERVICE); Intent notifyIntent = new Intent(ctx, AddUpdateNotificationActivity.class); notifyIntent.putExtra(BaseActivity.MODE_KEY, BaseActivity.PARAM_EDIT); notifyIntent.putExtra(BaseActivity.ENTITY_ID, id); notifyIntent.putExtra(BaseActivity.NOTIFY_EXTRA, true); notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); TaskStackBuilder stackBuilder = TaskStackBuilder.create(ctx); stackBuilder.addParentStack(AddUpdateNotificationActivity.class); stackBuilder.addNextIntent(notifyIntent); PendingIntent notifyPendingIntent = PendingIntent.getActivity(ctx, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(notifyPendingIntent); mBuilder.setAutoCancel(true); mNotificationManager.notify((int) id, mBuilder.build()); }
From source file:co.edu.uniajc.vtf.security.controller.CreateAccountController.java
public void navigateContent() { Activity loActivity = (Activity) coView; Intent loIntent = new Intent(loActivity, SwipeContentActivity.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); loActivity.startActivity(loIntent);/*from w ww .j av a 2 s . com*/ ((Activity) coView).finish(); }
From source file:com.aqnote.app.wifianalyzer.MainActivity.java
private void reloadActivity() { finish();/* w w w . j a v a2s . com*/ Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
From source file:com.openarc.nirmal.mytrack.CIRContactActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_about: AboutDialog();//from w w w .j a va2 s . c om break; case R.id.menu_logout: Intent intent = new Intent(getApplicationContext(), LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); break; } return super.onOptionsItemSelected(item); }
From source file:org.egov.android.view.activity.AccountActivationActivity.java
/** * The onResponse method will be invoked after the Account activation API call onResponse * methods will contain the response If the response has a status as 'success' then message is * displayed in toast. Finally calls the startLoginActivity() function and redirects to Login * Activity./*ww w .j a v a2 s. com*/ */ @Override public void onResponse(Event<ApiResponse> event) { super.onResponse(event); IApiUrl url = event.getData().getApiMethod().getApiUrl(); String status = event.getData().getApiStatus().getStatus(); String msg = event.getData().getApiStatus().getMessage(); showMessage(msg); if (status.equalsIgnoreCase("success")) { if (url.getUrl().equals(ApiUrl.VERIFY_OTP.getUrl())) { User user = new User(); user.setEmail(username); user.setPassword(password); ApiController.getInstance().login(this, user, baseServerURL); } else if (url.getUrl().equals(ApiUrl.LOGIN.getUrl())) { try { JSONArray ja = new JSONArray(event.getData().getResponse().toString()); JSONObject jo = ja.getJSONObject(0); getSession().edit().putString("access_token", jo.getString("access_token")).commit(); getSession().edit().putString("user_name", jo.getString("user_name")).commit(); Intent intent = new Intent(this, ComplaintActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); } catch (JSONException e) { e.printStackTrace(); } } } }
From source file:com.oakesville.mythling.MediaListActivity.java
public void refresh() { super.refresh(); getAppSettings().setLastLoad(0);/*from w ww .ja v a2 s . c o m*/ Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); }
From source file:org.cvasilak.jboss.mobile.app.service.UploadToJBossServerService.java
@Override protected void onHandleIntent(Intent intent) { // initialize // extract details Server server = intent.getParcelableExtra("server"); String directory = intent.getStringExtra("directory"); String filename = intent.getStringExtra("filename"); // get the json parser from the application JsonParser jsonParser = new JsonParser(); // start the ball rolling... final NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setTicker(String.format(getString(R.string.notif_ticker), filename)) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_notif_large)) .setSmallIcon(R.drawable.ic_stat_notif_small) .setContentTitle(String.format(getString(R.string.notif_title), filename)) .setContentText(getString(R.string.notif_content_init)) // to avoid NPE on android 2.x where content intent is required // set an empty content intent .setContentIntent(PendingIntent.getActivity(this, 0, new Intent(), 0)).setOngoing(true); // notify user that upload is starting mgr.notify(NOTIFICATION_ID, builder.build()); // reset ticker for any subsequent notifications builder.setTicker(null);/*from w w w . j a va 2 s .com*/ AbstractHttpClient client = CustomHTTPClient.getHttpClient(); // enable digest authentication if (server.getUsername() != null && !server.getUsername().equals("")) { Credentials credentials = new UsernamePasswordCredentials(server.getUsername(), server.getPassword()); client.getCredentialsProvider().setCredentials( new AuthScope(server.getHostname(), server.getPort(), AuthScope.ANY_REALM), credentials); } final File file = new File(directory, filename); final long length = file.length(); try { CustomMultiPartEntity multipart = new CustomMultiPartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, new CustomMultiPartEntity.ProgressListener() { @Override public void transferred(long num) { // calculate percentage //System.out.println("transferred: " + num); int progress = (int) ((num * 100) / length); builder.setContentText(String.format(getString(R.string.notif_content), progress)); mgr.notify(NOTIFICATION_ID, builder.build()); } }); multipart.addPart(file.getName(), new FileBody(file)); HttpPost httpRequest = new HttpPost(server.getHostPort() + "/management/add-content"); httpRequest.setEntity(multipart); HttpResponse serverResponse = client.execute(httpRequest); BasicResponseHandler handler = new BasicResponseHandler(); JsonObject reply = jsonParser.parse(handler.handleResponse(serverResponse)).getAsJsonObject(); if (!reply.has("outcome")) { throw new RuntimeException(getString(R.string.invalid_response)); } else { // remove the 'upload in-progress' notification mgr.cancel(NOTIFICATION_ID); String outcome = reply.get("outcome").getAsString(); if (outcome.equals("success")) { String BYTES_VALUE = reply.get("result").getAsJsonObject().get("BYTES_VALUE").getAsString(); Intent resultIntent = new Intent(this, UploadCompletedActivity.class); // populate it resultIntent.putExtra("server", server); resultIntent.putExtra("BYTES_VALUE", BYTES_VALUE); resultIntent.putExtra("filename", filename); resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); // the notification id for the 'completed upload' notification // each completed upload will have a different id int notifCompletedID = (int) System.currentTimeMillis(); builder.setContentTitle(getString(R.string.notif_title_uploaded)) .setContentText(String.format(getString(R.string.notif_content_uploaded), filename)) .setContentIntent( // we set the (2nd param request code to completedID) // see http://tinyurl.com/kkcedju PendingIntent.getActivity(this, notifCompletedID, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT)) .setAutoCancel(true).setOngoing(false); mgr.notify(notifCompletedID, builder.build()); } else { JsonElement elem = reply.get("failure-description"); if (elem.isJsonPrimitive()) { throw new RuntimeException(elem.getAsString()); } else if (elem.isJsonObject()) throw new RuntimeException( elem.getAsJsonObject().get("domain-failure-description").getAsString()); } } } catch (Exception e) { builder.setContentText(e.getMessage()).setAutoCancel(true).setOngoing(false); mgr.notify(NOTIFICATION_ID, builder.build()); } }