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.nanostuffs.yurdriver.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. */// www . j a v a2s . c o m private 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:no.ntnu.idi.socialhitchhiking.utility.ShareOnFacebook.java
/** * Post to facebook wall and goes back to main screen deleting activity stack. * @param button/* w w w. j a va2s . c o m*/ */ public void share(View button) { // if (! facebook.isSessionValid()) { // loginAndPostToWall(); // postToWall(messageToPost); // } // else { postToWall(messageToPost); Intent intent = new Intent(ShareOnFacebook.this, Main.class); startActivity(intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); // } }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
@SuppressLint("NewApi") @Override/* ww w .j av a 2 s . c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setWindowFeatures(); setContentView(R.layout.activity_view_pager); makeActionBarTransparent(); connection = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { mservice = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { mservice = IInAppBillingService.Stub.asInterface(service); } }; bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), connection, Context.BIND_AUTO_CREATE); File n = new File(Environment.getExternalStorageDirectory().getPath() + "/Pictures/.13linequran/13 line quran/881.jpg"); File file = new File(Environment.getExternalStorageDirectory().getPath() + "/Pictures/13linequran.zip"); if (file.exists() && n.exists()) file.delete(); if (!n.exists()) { Intent intent = new Intent(ViewPagerActivity.this, DownloadActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } sharedPref = this.getPreferences(Context.MODE_PRIVATE); editor = sharedPref.edit(); /*subscribed=sharedPref.getBoolean("subscribed", false); if(!subscribed) { subscribed=getIntent().getBooleanExtra("validated", false); if(subscribed==true) { editor.putBoolean("subscribed", true); editor.commit(); getIntent().removeExtra("validated"); getIntent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } } if(!subscribed){ Intent suscribe= new Intent(ViewPagerActivity.this,SubscriptionActivity.class); suscribe.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(suscribe); finish(); } */ //if(getIntent().getBooleanExtra("validated", true)==false){ if (getIntent().hasExtra("code") && sharedPref.getBoolean("done", false) == false || sharedPref.contains("code") && sharedPref.getBoolean("done", false) == false) { Log.e("place", "0"); if (getIntent().hasExtra("code")) { code = getIntent().getIntExtra("code", 0); email = getIntent().getStringExtra("email"); editor.putString("email", email); editor.putInt("code", code); editor.commit(); Log.e("place", sharedPref.getInt("code", 0) + ""); } if (!internetIsConnected(ViewPagerActivity.this)) { Log.e("place", "1"); } else if (internetIsConnected(ViewPagerActivity.this)) { Log.e("place", "2"); new SendTask().execute(); } } //} int index = 881; String page = ""; getOverflowMenu(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getOrient = getWindowManager().getDefaultDisplay(); mViewPager = (HackyViewPager) findViewById(R.id.view_pager); rated = false; rated = sharedPref.getBoolean("rated", false); mViewPager.setActionBar(getActionBar()); mViewPager.setAdapter(new SamplePagerAdapter()); mViewPager.setCurrentItem(index); if (sharedPref.getInt("continuePage", -1) != -1) { index = (sharedPref.getInt("continuePage", -1)); } try { Intent intent = getIntent(); page = intent.getStringExtra("PAGE"); index = Integer.parseInt(page); Log.e("Page", page); } catch (NullPointerException d) { Log.e("Page", "none1"); } catch (RuntimeException e) { Log.e("Page", "none" + e); } mViewPager.setCurrentItem(index); mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java
private void onUnhandled(Context context, Intent intent) { String action = intent.getAction(); if ((MFPPushUtils.getIntentPrefix(context) + GCM_MESSAGE).equals(action)) { MFPInternalPushMessage message = intent.getParcelableExtra(GCM_EXTRA_MESSAGE); int notificationId = randomObj.nextInt(); message.setNotificationId(notificationId); saveInSharedPreferences(message); intent = new Intent(MFPPushUtils.getIntentPrefix(context) + IBM_PUSH_NOTIFICATION); intent.setClass(context, MFPPushNotificationHandler.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(NOTIFICATIONID, message.getNotificationId()); generateNotification(context, message.getAlert(), getNotificationTitle(context), message.getAlert(), getCustomNotificationIcon(context, message.getIcon()), intent, getNotificationSound(message), notificationId, message); }/*from www.jav a 2 s . c o m*/ }
From source file:au.com.websitemasters.schools.thornlie.push.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 a2 s . c o m */ private void sendNotification(String message, Class clas) { //load not readed. +1. save em. int notReaded = ((SchoolsApplication) getApplicationContext()).loadBadgesCount(); notReaded = notReaded + 1; ((SchoolsApplication) getApplicationContext()).saveBadgesCount(notReaded); //show it on badge. ShortcutBadger.applyCount(getApplicationContext(), notReaded); Intent intent = new Intent(this, clas); 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.logopush).setContentTitle("Sacred Heart School Thornlie") .setContentText(message).setAutoCancel(true).setNumber(notReaded).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); //push realtime refresh of lists (ANN) Intent intentBroadcast = new Intent(BROADCAST_ACTION); sendBroadcast(intentBroadcast); }
From source file:com.airflo.preferences.ListPreferenceActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent returnIntent = new Intent(); returnIntent.putExtra("result", "justADummy"); setResult(1, returnIntent);/*from w w w . j a v a 2 s . co m*/ Intent intent = new Intent(this, FlightListActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Resume saved // State! NavUtils.navigateUpTo(this, intent); return true; } return super.onOptionsItemSelected(item); }
From source file:com.aniruddhc.acemusic.player.AsyncTasks.AsyncGoogleMusicAuthenticationTask.java
@Override protected void onPostExecute(String result) { super.onPostExecute(result); if (mFirstRun) { pd.dismiss();/* w w w . ja v a 2 s . co m*/ } //Perform an action based on the operation's result code. if (result.equals("GOOGLE_PLAY_SERVICES_AVAILABILITY_EXCEPTION")) { Dialog d = GooglePlayServicesUtil.getErrorDialog(availabilityExceptionStatusCode, mActivity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR); d.show(); } else if (result.equals("USER_RECOVERABLE_AUTH_EXCEPTION")) { //45 is an arbitrary value that identifies this activity's result. LauncherActivity.mAccountName = mAccountName; SettingsActivity____.mAccountName = mAccountName; if (mActivity != null) { mActivity.startActivityForResult(userRecoverableExceptionIntent, 45); } } else if (result.equals("GOOGLE_AUTH_EXCEPTION") || result.equals("GENERIC_EXCEPTION")) { Toast.makeText(mContext, R.string.unknown_error_google_music, Toast.LENGTH_LONG).show(); } else if (result.equals("AUTHENTICATED")) { if (mFirstRun) { String text = mContext.getResources().getString(R.string.signed_in_as) + " " + mAccountName; Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show(); } else if (mFirstRunFromSettings) { //Start scanning the library to add GMusic songs. String text = mContext.getResources().getString(R.string.signed_in_as) + " " + mAccountName; Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show(); //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. final Intent i = mActivity.getBaseContext().getPackageManager() .getLaunchIntentForPackage(mActivity.getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mActivity.finish(); mActivity.startActivity(i); } mApp.getSharedPreferences().edit().putBoolean("GOOGLE_PLAY_MUSIC_ENABLED", true).commit(); } else { Toast.makeText(mContext, R.string.unknown_error_google_music, Toast.LENGTH_LONG).show(); } }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
private void invokeActivity1(String title, int resId) { Intent intent = new Intent(this, BaseMenuActivity.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/*from w w w . j a v a 2s . c om*/ // no animation of transition overridePendingTransition(0, 0); }
From source file:jahirfiquitiva.iconshowcase.services.NotificationsService.java
@SuppressWarnings("ResourceAsColor") private void pushNotification(String content, int type, int ID) { Preferences mPrefs = new Preferences(this); String appName = Utils.getStringFromResources(this, R.string.app_name); String title = appName, notifContent = null; switch (type) { case 1:/*from w w w . j a v a2 s . c om*/ title = getResources().getString(R.string.new_walls_notif_title, appName); notifContent = getResources().getString(R.string.new_walls_notif_content, content); break; case 2: title = appName + " " + getResources().getString(R.string.news).toLowerCase(); notifContent = content; break; } // Send Notification NotificationManager notifManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this); notifBuilder.setAutoCancel(true); notifBuilder.setContentTitle(title); if (notifContent != null) { notifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(notifContent)); notifBuilder.setContentText(notifContent); } notifBuilder.setTicker(title); Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); notifBuilder.setSound(ringtoneUri); if (mPrefs.getNotifsVibrationEnabled()) { notifBuilder.setVibrate(new long[] { 500, 500 }); } else { notifBuilder.setVibrate(null); } int ledColor = ThemeUtils.darkTheme ? ContextCompat.getColor(this, R.color.dark_theme_accent) : ContextCompat.getColor(this, R.color.light_theme_accent); notifBuilder.setColor(ledColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notifBuilder.setPriority(Notification.PRIORITY_HIGH); } Class appLauncherActivity = getLauncherClass(getApplicationContext()); if (appLauncherActivity != null) { Intent appIntent = new Intent(this, appLauncherActivity); appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); appIntent.putExtra("notifType", type); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(appLauncherActivity); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(appIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); notifBuilder.setContentIntent(resultPendingIntent); } notifBuilder.setOngoing(false); notifBuilder.setSmallIcon(R.drawable.ic_notifications); Notification notif = notifBuilder.build(); if (mPrefs.getNotifsLedEnabled()) { notif.ledARGB = ledColor; } notifManager.notify(ID, notif); }
From source file:com.firesoft.member.Activity.B0_SigninActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { if (isExit == false) { isExit = true;// w w w. j a v a 2 s . com ToastView toast = new ToastView(getApplicationContext(), getString(R.string.exit_again)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); handler.sendEmptyMessageDelayed(0, 3000); return true; } else { if (SESSION.getInstance().uid == 0) { finish(); } else { Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } return false; } } return true; }