List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
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:org.bfr.periodicquery.PeriodicQueryService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { // The intent to launch when the user clicks the expanded notification Intent launchIntent = new Intent(this, StartStopActivity.class); launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, launchIntent, 0); // This constructor is deprecated. Use Notification.Builder instead Notification notice = new Notification(R.drawable.ic_launcher, "Periodic Query", System.currentTimeMillis()); // This method is deprecated. Use Notification.Builder instead. notice.setLatestEventInfo(this, "Periodic Query", "Periodic Query", pendIntent); notice.flags |= Notification.FLAG_NO_CLEAR; startForeground(1234, notice);/*from ww w .j a va2s . c o m*/ return START_STICKY; }
From source file:samples.piggate.com.piggateCompleteExample.Activity_SingUp.java
public void backButton() { Intent slideactivity = new Intent(Activity_SingUp.this, Activity_Main.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromleft, R.anim.slidetoright).toBundle(); startActivity(slideactivity, bndlanimation); }
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 ww. jav a 2 s .c om 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; }
From source file:com.insthub.O2OMobile.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;// ww w . j a v a2s .c o m 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, SlidingActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } return false; } } return true; }
From source file:com.oakesville.mythling.MainActivity.java
public void onBackPressed() { if (EpgActivity.class.getName().equals(backTo) || FireTvEpgActivity.class.getName().equals(backTo)) { Intent a = new Intent(Intent.ACTION_MAIN); a.addCategory(Intent.CATEGORY_HOME); a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(a);/*ww w .j av a 2s .c om*/ } else { super.onBackPressed(); } }
From source file:com.example.android.samplesync.syncadapter.SyncAdapter.java
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {// w w w . j a v a2s. c om Log.e(TAG, "SyncAdapter==============onPerformSync"); try { // see if we already have a sync-state attached to this account. By // handing // This value to the server, we can just get the contacts that have // been updated on the server-side since our last sync-up long lastSyncMarker = getServerSyncMarker(account); // By default, contacts from a 3rd party provider are hidden in the // contacts // list. So let's set the flag that causes them to be visible, so // that users // can actually see these contacts. if (lastSyncMarker == 0) { ContactManager.setAccountContactsVisibility(getContext(), account, true); } List<RawContact> dirtyContacts; List<RawContact> updatedContacts; // Use the account manager to request the AuthToken we'll need // to talk to our sample server. If we don't have an AuthToken // yet, this could involve a round-trip to the server to request // and AuthToken. final String authtoken = mAccountManager.blockingGetAuthToken(account, Constants.AUTHTOKEN_TYPE, NOTIFY_AUTH_FAILURE); // Make sure that the sample group exists final long groupId = ContactManager.ensureSampleGroupExists(mContext, account); // Find the local 'dirty' contacts that we need to tell the server // about... // Find the local users that need to be sync'd to the server... dirtyContacts = ContactManager.getDirtyContacts(mContext, account); // Send the dirty contacts to the server, and retrieve the // server-side changes updatedContacts = NetworkUtilities.syncContacts(account, authtoken, lastSyncMarker, dirtyContacts); // Update the local contacts database with the changes. // updateContacts() // returns a syncState value that indicates the high-water-mark for // the changes we received. Log.d(TAG, "Calling contactManager's sync contacts"); long newSyncState = ContactManager.updateContacts(mContext, account.name, updatedContacts, groupId, lastSyncMarker); // This is a demo of how you can update IM-style status messages // for contacts on the client. This probably won't apply to // 2-way contact sync providers - it's more likely that one-way // sync providers (IM clients, social networking apps, etc) would // use this feature. ContactManager.updateStatusMessages(mContext, updatedContacts); // Save off the new sync marker. On our next sync, we only want to // receive // contacts that have changed since this sync... setServerSyncMarker(account, newSyncState); if (dirtyContacts.size() > 0) { ContactManager.clearSyncFlags(mContext, dirtyContacts); } } catch (final AuthenticatorException e) { Log.e(TAG, "AuthenticatorException", e); syncResult.stats.numParseExceptions++; } catch (final OperationCanceledException e) { Log.e(TAG, "OperationCanceledExcetpion", e); } catch (final IOException e) { Log.e(TAG, "IOException", e); syncResult.stats.numIoExceptions++; } catch (final AuthenticationException e) { Log.e(TAG, "AuthenticationException", e); syncResult.stats.numAuthExceptions++; } catch (final ParseException e) { Log.e(TAG, "ParseException", e); syncResult.stats.numParseExceptions++; } catch (final JSONException e) { Log.e(TAG, "JSONException", e); syncResult.stats.numParseExceptions++; } // Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClass(mContext.getApplicationContext(), AuthenticatorActivity.class); mContext.startActivity(intent); }
From source file:com.loadsensing.app.ImatgeXarxaSensors.java
public void goHome(Context context) { final Intent intent = new Intent(context, HomeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(intent);//from w w w . jav a2s . com }
From source file:com.android.idearse.Login.java
public void onBackPressed() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);//from w ww .j a v a 2 s . c o m }
From source file:com.naddysworld.slingshot.Main.java
public void onActionBarItemSelected(View v) { // Example of how to handle action bar item selections. // Adjust, insert and/or remove case statements for your menu items // accordingly. switch (v.getId()) { // when app icon in action bar or action bar title is clicked, show // home/main activity case R.id.applicationIcon: case R.id.actionBarTitle: Intent intent = new Intent(this, com.naddysworld.slingshot.Main.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);//from w ww. j a va 2 s.c om break; case R.id.menuItem1: startActivity(new Intent(this, Preferences.class)); break; case R.id.menuItem2: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (prefs.getString("username", "").equals("") || prefs.getString("password", "").equals("")) startActivity(new Intent(this, Preferences.class)); else new UpdateStationsTask().execute(); break; default: } }