List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:fib.lcfib.raco.Controladors.ControladorLoginRaco.java
private void showAddDialog() { loginDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); loginDialog.setTitle(R.string.loginRaco); LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogView = li.inflate(R.layout.contingut_login, null); loginDialog.setContentView(dialogView); username = (EditText) dialogView.findViewById(R.id.login); password = (EditText) dialogView.findViewById(R.id.password); Button okButton = (Button) dialogView.findViewById(R.id.acceptar_button); Button cancelButton = (Button) dialogView.findViewById(R.id.cancel_button); loginDialog.setCancelable(false);/*from w w w . j ava 2 s . co m*/ loginDialog.show(); okButton.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { try { String usernameAux = username.getText().toString().trim(); String passwordAux = password.getText().toString().trim(); usernameAux = URLEncoder.encode(usernameAux, "UTF-8"); passwordAux = URLEncoder.encode(passwordAux, "UTF-8"); boolean correcte = check_user(usernameAux, passwordAux); if (correcte) { Toast.makeText(getApplicationContext(), R.string.login_correcte, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); } if ("zonaRaco".equals(queEs)) { Intent intent = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("esLogin", "zonaRaco"); startActivity(intent); } else { Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); // Aquestes 2 lnies provoquen una excepci per no peta // simplement informa s normal act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(act); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } private boolean check_user(String username, String password) { GestorCertificats.allowAllSSL(); AndroidUtils au = AndroidUtils.getInstance(); /** open connection */ //Aix tanquem les connexions segur System.setProperty("http.keepAlive", "false"); try { InputStream is = null; HttpGet request = new HttpGet(au.URL_LOGIN + "username=" + username + "&password=" + password); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Header[] headers = response.getHeaders("Location"); if (headers != null && headers.length != 0) { String newUrl = headers[headers.length - 1].getValue(); request = new HttpGet(newUrl); client.execute(request); } } /** Get Keys */ is = response.getEntity().getContent(); ObjectMapper m = new ObjectMapper(); JsonNode rootNode = m.readValue(is, JsonNode.class); is.close(); client.getConnectionManager().closeExpiredConnections(); if (rootNode.isNull()) { return false; } else { // GenerarUrl(); /** calendari ics */ String KEYportadaCal = rootNode.path("/ical/portada.ics").getTextValue().toString(); /** calendari rss */ String KEYportadaRss = rootNode.path("/ical/portada.rss").getTextValue().toString(); /** Avisos */ String KEYavisos = rootNode.path("/extern/rss_avisos.jsp").getTextValue().toString(); /** Assigraco */ String KEYAssigRaco = rootNode.path("/api/assigList").getTextValue().toString(); /** Horari */ String KEYIcalHorari = rootNode.path("/ical/horari.ics").getTextValue().toString(); /**Notificacions */ String KEYRegistrar = rootNode.path("/api/subscribeNotificationSystem").getTextValue() .toString(); String KEYDesregistrar = rootNode.path("/api/unsubscribeNotificationSystem").getTextValue() .toString(); SharedPreferences sp = getSharedPreferences(PreferenciesUsuari.getPreferenciesUsuari(), MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); /** Save Username and Password */ editor.putString(AndroidUtils.USERNAME, username); editor.putString(AndroidUtils.PASSWORD, password); /** Save Keys */ editor.putString(au.KEY_AGENDA_RACO_XML, KEYportadaRss); editor.putString(au.KEY_AGENDA_RACO_CAL, KEYportadaCal); editor.putString(au.KEY_AVISOS, KEYavisos); editor.putString(au.KEY_ASSIG_FIB, "public"); editor.putString(au.KEY_ASSIGS_RACO, KEYAssigRaco); editor.putString(au.KEY_HORARI_RACO, KEYIcalHorari); editor.putString(au.KEY_NOTIFICACIONS_REGISTRAR, KEYRegistrar); editor.putString(au.KEY_NOTIFICACIONS_DESREGISTRAR, KEYDesregistrar); /** Save changes */ editor.commit(); } return true; } catch (ProtocolException e) { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); return false; } catch (IOException e) { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); return false; } } }); cancelButton.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(act); } }); }
From source file:com.app.basarnas.fcm.MyFirebaseMessagingService.java
private void sendNotification() { Intent intent = new Intent(this, MainActivity.class); intent.putExtra(Config.JSON_DATA_NOTIFICATION, jsonDataNotification); intent.setAction(Intent.ACTION_MAIN); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setStyle(new NotificationCompat.BigTextStyle().bigText(dataNotification.getText())) .setSmallIcon(R.mipmap.ic_launcher, 10) .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary)) .setContentTitle(dataNotification.getTitle()) .setContentText(CommonUtilities.toHtml(dataNotification.getText())) .setPriority(NotificationCompat.PRIORITY_HIGH).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(Config.NOTIFICATION_ID /* ID of notification */, notificationBuilder.build()); }
From source file:com.barelabor.barelabor.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from ww w .j av a 2s . com*/ */ private void sendNotification(String repairArrayString, String highCostArrayString, String averageCostArrayString, String lowCostArrayString, String lowPrice, String highPrice, String avgPrice) { // String lowPrice = "0", highPrice = "0", avgPrice = "0"; // try { // JSONArray data = new JSONArray(message); // lowPrice = data.getJSONObject(0).getString("lowCost"); // avgPrice = data.getJSONObject(0).getString("averageCost"); // highPrice = data.getJSONObject(0).getString("highCost"); // } catch (JSONException e) { // e.printStackTrace(); // } Intent intent = new Intent(this, MenuActivity.class); intent.putExtra("low_price", lowPrice); intent.putExtra("high_price", highPrice); intent.putExtra("avg_price", avgPrice); intent.putExtra("repairArrayString", repairArrayString); intent.putExtra("highCostArrayString", highCostArrayString); intent.putExtra("averageCostArrayString", averageCostArrayString); intent.putExtra("lowCostArrayString", lowCostArrayString); intent.putExtra("notification", true); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("BareLabor") .setContentText("The pricing for your printed estimate has arrived").setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.google.android.gcm.demo.app.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///w w w. ja v a 2 s .c om private static void generateNotification(Context context, String message, String data) { int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(0); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, DemoActivity.class); notificationIntent.putExtra(CommonUtilities.EXTRA_TEAM_IN_JSON, data); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.flags = Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:com.frostwire.android.gui.util.UIUtils.java
public static void sendGoHomeIntent(Context ctx) { Intent i = new Intent(ctx, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra("gohome-frostwire", true); ctx.startActivity(i);// ww w.ja v a2 s. co m }
From source file:com.netpace.expressit.activity.UploadImageStoryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: if (!isGalleryPhoto) { this.onBackPressed(); } else {// www .j a v a2 s . c o m Intent intent = new Intent(UploadImageStoryActivity.this, MediaOptionsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } return true; case R.id.menu_item_img_gallery: if (isValidate()) { // close the keyboard. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(titleTextView.getWindowToken(), 0); getMediaKeyFromRemoteServer(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.appdynamics.demo.gasp.gcm.GCMIntentService.java
/** * Send a notification message that a new update has been received * * @param msg Notification message//from ww w . jav a2 s . c om */ private void sendNotification(String msg) { NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, LocationsActivity.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle("Gasp! Update") .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.afrolkin.samplepushclient.GCMIntentService.java
private static void generateNotification(Context context, String message) { int icon = R.mipmap.ic_announcement_black_48dp; long when = System.currentTimeMillis(); String title = context.getString(R.string.app_name); Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, "Push Message", when); notification.sound = soundUri;// ww w . j av a 2 s . c om Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.putExtra("message", message); // Set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:butter.droid.base.torrent.TorrentService.java
public void startForeground() { if (Foreground.get().isForeground()) return;//from w w w . ja va 2 s .c om if (mCurrentActivityClass == null) return; Intent notificationIntent = new Intent(this, mCurrentActivityClass); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); Intent stopIntent = new Intent(); stopIntent.setAction(TorrentBroadcastReceiver.STOP); PendingIntent pendingStopIntent = PendingIntent.getBroadcast(this, TorrentBroadcastReceiver.REQUEST_CODE, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action stopAction = new NotificationCompat.Action.Builder( R.drawable.abc_ic_clear_mtrl_alpha, getString(R.string.stop), pendingStopIntent).build(); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notif_logo) .setContentTitle(getString(R.string.app_name) + " - " + getString(R.string.running)) .setContentText(getString(R.string.tap_to_resume)).setOngoing(true).setOnlyAlertOnce(true) .setPriority(Notification.PRIORITY_LOW).setContentIntent(pendingIntent).addAction(stopAction) .setCategory(NotificationCompat.CATEGORY_SERVICE); if (mStreamStatus != null && mIsReady) { String downloadSpeed; DecimalFormat df = new DecimalFormat("#############0.00"); if (mStreamStatus.downloadSpeed / 1024 < 1000) { downloadSpeed = df.format(mStreamStatus.downloadSpeed / 1024) + " KB/s"; } else { downloadSpeed = df.format(mStreamStatus.downloadSpeed / (1024 * 1024)) + " MB/s"; } String progress = df.format(mStreamStatus.progress); builder.setContentText(progress + "%, " + downloadSpeed); } Notification notification = builder.build(); NotificationManager notifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notifManager.notify(NOTIFICATION_ID, notification); startForeground(NOTIFICATION_ID, notification); if (mUpdateTimer == null) { mUpdateTimer = new Timer(); mUpdateTimer.scheduleAtFixedRate(new UpdateTask(), 5000, 5000); } }
From source file:com.fabernovel.alertevoirie.MyIncidentsActivity.java
/** Called when the activity is first created. */ @Override/*from w w w. j a va 2s .co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.layout_report_lists); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon_mes_rapports); tabs = (RadioGroup) findViewById(R.id.RadioGroup_tabs); tbmap = (ToggleButton) findViewById(R.id.ToggleButton01); tbmap.setChecked(false); tbmap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { tbmap.setChecked(false); Intent i = new Intent(MyIncidentsActivity.this, MyIncidentsActivityMap.class); i.putExtra("tab1", title[0]); i.putExtra("tab2", title[1]); i.putExtra("tab3", title[2]); i.putExtra("datas", data.toString()); i.putExtra("tab", checked); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);// .addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(i); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } } }); if (getIntent().getExtras() != null) { title[0] = getIntent().getExtras().getString("tab1"); title[1] = getIntent().getExtras().getString("tab2"); title[2] = getIntent().getExtras().getString("tab3"); ((TextView) tabs.getChildAt(0)).setText(title[0]); if (title[0].startsWith("0")) ((TextView) tabs.getChildAt(0)).setEnabled(false); ((TextView) tabs.getChildAt(1)).setText(title[1]); if (title[1].startsWith("0")) ((TextView) tabs.getChildAt(1)).setEnabled(false); ((TextView) tabs.getChildAt(2)).setText(title[2]); if (title[2].startsWith("0")) ((TextView) tabs.getChildAt(2)).setEnabled(false); checked = getIntent().getExtras().getInt("tab"); try { data = new JSONObject(getIntent().getExtras().getString("datas")); } catch (JSONException e) { Log.e(Constants.PROJECT_TAG, "JSon data exception", e); } setAdapterForTab(gettabIndex(tabs.getCheckedRadioButtonId())); } else { // sendRequest(); } // get view references tabs.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { Log.d(Constants.PROJECT_TAG, "checked : " + checkedId); checked = checkedId; setAdapterForTab(gettabIndex(checkedId)); } }); tabs.check(getId()); }