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:com.mjhram.ttaxi.gcm_client.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w. j a v a 2 s.c o m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, GpsMainActivity.class); 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.drawable.circle_green).setContentTitle(getString(R.string.gcmClientGcmMsg)) .setContentText(message).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.androzic.navigation.NavigationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { Intent activity = new Intent(this, MainActivity.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); String action = intent.getAction(); if (action == null) return 0; Bundle extras = intent.getExtras(); if (action.equals(NAVIGATE_MAPOBJECT)) { MapObject mo = new MapObject(); mo.name = extras.getString(EXTRA_NAME); mo.latitude = extras.getDouble(EXTRA_LATITUDE); mo.longitude = extras.getDouble(EXTRA_LONGITUDE); mo.proximity = extras.getInt(EXTRA_PROXIMITY); activity.putExtra(MainActivity.LAUNCH_ACTIVITY, HSIActivity.class); contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, activity, PendingIntent.FLAG_CANCEL_CURRENT); navigateTo(mo);/*from w w w. j a va 2 s.c o m*/ } if (action.equals(NAVIGATE_MAPOBJECT_WITH_ID)) { long id = extras.getLong(EXTRA_ID); MapObject mo = application.getMapObject(id); if (mo == null) return 0; activity.putExtra(MainActivity.LAUNCH_ACTIVITY, HSIActivity.class); contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, activity, PendingIntent.FLAG_CANCEL_CURRENT); navigateTo(mo); } if (action.equals(NAVIGATE_ROUTE)) { int index = extras.getInt(EXTRA_ROUTE_INDEX); int dir = extras.getInt(EXTRA_ROUTE_DIRECTION, DIRECTION_FORWARD); int start = extras.getInt(EXTRA_ROUTE_START, -1); activity.putExtra(MainActivity.SHOW_FRAGMENT, RouteDetails.class); activity.putExtra("index", index); contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, activity, PendingIntent.FLAG_CANCEL_CURRENT); Route route = application.getRoute(index); if (route == null) return 0; navigateTo(route, dir); if (start != -1) setRouteWaypoint(start); } } return START_STICKY; }
From source file:com.memetro.android.oauth.OAuth.java
public JSONObject call(String controller, String action, Map<String, String> params) { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(oauthServer + controller + "/" + action); try {/*from w w w .j av a 2s . c o m*/ // Add data httppost.setEntity(new UrlEncodedFormEntity(Map2NameValuePair(params))); // Execute Post HttpResponse response = httpclient.execute(httppost); // Catch headers int statusCode = response.getStatusLine().getStatusCode(); lastHttpStatus = statusCode; if (statusCode != 200) { JSONObject returnJ = new JSONObject(); returnJ.put("success", false); returnJ.put("data", new JSONArray()); Log.d("Http Status Code", String.valueOf(statusCode)); switch (statusCode) { case 401: if (refreshToken() && firstAuthCall) { firstAuthCall = false; Utils utils = new Utils(); params.put("access_token", utils.getToken(context)); return call(controller, action, params); } returnJ.put("message", context.getString(R.string.session_expired)); Utils utils = new Utils(); utils.setToken(context, "", ""); Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return returnJ; case 404: returnJ.put("message", context.getString(R.string.action_not_found)); return returnJ; case 500: returnJ.put("message", context.getString(R.string.server_error)); return returnJ; default: returnJ.put("message", context.getString(R.string.internal_error)); return returnJ; } } BufferedReader reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), "UTF-8")); String json = reader.readLine(); JSONTokener tokener = new JSONTokener(json); return new JSONObject(tokener); } catch (ClientProtocolException e) { // TODO Auto-generated catch block } catch (JSONException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } return new JSONObject(); }
From source file:com.frostwire.android.gui.util.UIUtils.java
public static void sendShutdownIntent(Context ctx) { Intent i = new Intent(ctx, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra("shutdown-frostwire", true); ctx.startActivity(i);/* ww w.ja v a2 s. c o m*/ }
From source file:com.aniruddhc.acemusic.player.SettingsActivity.PreferenceDialogLauncherActivity.java
@Override public void onCreate(Bundle savedInstanceState) { mContext = this; mApp = (Common) mContext.getApplicationContext(); if (mApp.getCurrentTheme() == Common.DARK_THEME) { this.setTheme(R.style.AppThemeTransparent); } else {//from www. j a v a 2s . com this.setTheme(R.style.AppThemeTransparentLight); } super.onCreate(savedInstanceState); //Get the index that specifies which dialog to launch. int index = getIntent().getExtras().getInt("INDEX"); if (index == 0) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ApplicationThemeDialog appThemeDialog = new ApplicationThemeDialog(); //appThemeDialog.show(ft, "appThemeDialog"); } else if (index == 1) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); NowPlayingColorSchemesDialog appThemeDialog = new NowPlayingColorSchemesDialog(); //appThemeDialog.show(ft, "colorSchemesDialog"); } else if (index == 2) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); CustomizeScreensDialog screensDialog = new CustomizeScreensDialog(); screensDialog.show(ft, "customizeScreensDialog"); } else if (index == 3) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); CoverArtStyleDialog coverArtStyleDialog = new CoverArtStyleDialog(); coverArtStyleDialog.show(ft, "coverArtStyleDialog"); } else if (index == 4) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); AlbumArtSourceDialog albumArtSourceDialog = new AlbumArtSourceDialog(); albumArtSourceDialog.show(ft, "albumArtSourceDialog"); } else if (index == 5) { } else if (index == 6) { //Seting the "REBUILD_LIBRARY" flag to true will force MainActivity to rescan the folders. mApp.getSharedPreferences().edit().putBoolean("REBUILD_LIBRARY", true).commit(); //Restart the app. Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); finish(); startActivity(i); } else if (index == 7) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putBoolean("CALLED_FROM_WELCOME", false); ScanFrequencyDialog scanFrequencyDialog = new ScanFrequencyDialog(); scanFrequencyDialog.setArguments(bundle); scanFrequencyDialog.show(ft, "scanFrequencyDialog"); } else if (index == 8) { /* FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); BlacklistManagerDialog blacklistDialog = new BlacklistManagerDialog(); blacklistDialog.show(ft, "blacklistManagerDialog");*/ FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); BlacklistedElementsDialog dialog = new BlacklistedElementsDialog(); Bundle bundle = new Bundle(); bundle.putString("MANAGER_TYPE", "ARTISTS"); dialog.setArguments(bundle); dialog.show(ft, "blacklistedElementsDialog"); } else if (index == 9) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putBoolean("CALLED_FROM_WELCOME", false); ScanFrequencyDialog scanFrequencyDialog = new ScanFrequencyDialog(); scanFrequencyDialog.setArguments(bundle); scanFrequencyDialog.show(ft, "scanFrequencyDialog"); } else if (index == 12) { /*FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); LicensesDialog appThemeDialog = new LicensesDialog(); appThemeDialog.show(ft, "licensesDialog");*/ new LicensesDialog(this, R.raw.notices, false, false).show(); } else if (index == 13) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); AddMusicLibraryDialog addMusicLibraryDialog = new AddMusicLibraryDialog(); addMusicLibraryDialog.show(ft, "addMusicLibraryDialog"); } else if (index == 14) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); EditDeleteMusicLibraryDialog deleteMusicLibraryDialog = new EditDeleteMusicLibraryDialog(); Bundle bundle = getIntent().getExtras(); deleteMusicLibraryDialog.setArguments(bundle); deleteMusicLibraryDialog.show(ft, "editDeleteMusicLibraryDialog"); } else if (index == 15) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); GooglePlayMusicAuthenticationDialog dialog = new GooglePlayMusicAuthenticationDialog(); Bundle bundle = new Bundle(); bundle.putBoolean(Common.FIRST_RUN, false); dialog.setArguments(bundle); dialog.show(ft, "gMusicAuthDialog"); } }
From source file:andre.com.datapushandroid.services.FCMService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *//*from w ww . ja v a 2s. c om*/ private void sendNotification(String messageBody) { Intent intent = new Intent(this, MainActivity.class); 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("FCM Message").setContentText(messageBody) .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.ayuget.redface.ui.activity.BaseActivity.java
public void refreshTheme() { finish();/*from www. jav a 2 s .c o m*/ Intent intent = new Intent(this, TopicsActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); finish(); }
From source file:com.rocketsingh.biker.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//*w ww . j a va 2 s . co m*/ public static void generateNotification(Context context, String message) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MapActivity.class); notificationIntent.putExtra("fromNotification", "notification"); // 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; System.out.println("notification====>" + message); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; // notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0x00000000; notification.ledOnMS = 0; notification.ledOffMS = 0; notificationManager.notify(AndyConstants.NOTIFICATION_ID, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "WakeLock"); wakeLock.acquire(); wakeLock.release(); }
From source file:jp.co.ipublishing.esnavi.impl.gcm.GcmIntentService.java
/** * Notification??// w w w. ja va 2 s . c om * * @param alert */ private void sendNotification(@NonNull Alert alert) { final NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); final Intent resultIntent = new Intent(this, MapActivity.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent contentIntent = PendingIntent.getActivity(this, 1, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); final Notification.Builder builder = new Notification.Builder(this).setWhen(System.currentTimeMillis()) .setContentIntent(contentIntent) .setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS) .setAutoCancel(true).setTicker(alert.getHeadlineBody()).setContentText(alert.getHeadlineBody()); onPreSendNotification(builder, alert); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notificationManager.notify(NOTIFICATION_ID, builder.build()); } else { notificationManager.notify(NOTIFICATION_ID, builder.getNotification()); } }