List of usage examples for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
To view the source code for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.
Click Source Link
From source file:com.cleanwiz.applock.ui.activity.SplashActivity.java
public void createDeskShortCut() { // ????//from w w w . ja va2 s.c o m SharedPreferenceUtil.editShortCut(true); Intent shortcutIntent = new Intent(); shortcutIntent.setClass(this, SplashActivity.class); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); shortcutIntent.setAction("android.intent.action.MAIN"); shortcutIntent.addCategory("android.intent.category.LAUNCHER"); Intent resultIntent = new Intent(); resultIntent.putExtra("duplicate", false); resultIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); resultIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); resultIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); resultIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); sendBroadcast(resultIntent); resultIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(resultIntent); }
From source file:com.nbplus.vbroadlauncher.HomeLauncherActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean isTablet = DisplayUtils.isTabletDevice(this); LauncherSettings.getInstance(this).setIsSmartPhone(!isTablet); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); setContentView(R.layout.activity_home_launcher); DeviceUtils.showDeviceInformation(); Log.d(TAG, ">>>DisplayUtils.getScreenDensity(this) = " + DisplayUtils.getScreenDensity(this)); // vitamio library load if (!LibsChecker.checkVitamioLibs(this)) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override//from w ww. j a va 2 s. c o m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alert.setMessage(R.string.alert_media_message); alert.show(); return; } mCurrentLocale = getResources().getConfiguration().locale; if (BuildConfig.DEBUG) { Point p = DisplayUtils.getScreenSize(this); Log.d(TAG, "Screen size px = " + p.x + ", py = " + p.y); Point screen = p; p = DisplayUtils.getScreenDp(this); Log.d(TAG, "Screen dp x = " + p.x + ", y = " + p.y); int density = DisplayUtils.getScreenDensity(this); Log.d(TAG, "Screen density = " + density); } if (isTablet) { //is tablet Log.d(TAG, "Tablet"); } else { //is phone Log.d(TAG, "isTabletDevice() returns Phone.. now check display inches"); double diagonalInches = DisplayUtils.getDisplayInches(this); if (diagonalInches >= 6.4) { // 800x400 ? portrait ? 6.43 ? . // 6.5inch device or bigger Log.d(TAG, "DisplayUtils.getDisplayInches() bigger than 6.5"); } else { if (!Constants.OPEN_BETA_PHONE) { // smaller device Log.d(TAG, "DisplayUtils.getDisplayInches() smaller than 6.5"); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alert.setMessage(R.string.alert_phone_message); alert.show(); return; } } } if (!Constants.OPEN_BETA_PHONE || !LauncherSettings.getInstance(this).isSmartPhone()) { if (isMyLauncherDefault()) { Log.d(TAG, "isMyLauncherDefault() == true"); // fake home key event. Intent fakeIntent = new Intent(); fakeIntent.setAction(Intent.ACTION_MAIN); fakeIntent.addCategory(Intent.CATEGORY_HOME); fakeIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(fakeIntent); } else { Log.d(TAG, "Constants.OPEN_BETA_PHONE == false || isMyLauncherDefault() == false"); //resetPreferredLauncherAndOpenChooser(); } } // ? .. ? ? ?. // ? ?. IntentFilter filter = new IntentFilter(); filter.addAction(Constants.ACTION_LAUNCHER_ACTIVITY_RUNNING); filter.addAction(IoTConstants.ACTION_RECEIVE_EMERGENCY_CALL_DEVICE_BROADCAST); LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter); Intent intent = new Intent(Constants.ACTION_LAUNCHER_ACTIVITY_RUNNING); mActivityRunningTime = System.currentTimeMillis(); intent.putExtra(Constants.EXTRA_LAUNCHER_ACTIVITY_RUNNING, mActivityRunningTime); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); // set background image setContentViewByOrientation(); if (LauncherSettings.getInstance(this).getPreferredUserLocation() == null) { Location defaultLocation = new Location("stub"); defaultLocation.setLongitude(126.929810); defaultLocation.setLatitude(37.488201); LauncherSettings.getInstance(this).setPreferredUserLocation(defaultLocation); } // First we need to check availability of play services mResultReceiver = new AddressResultReceiver(mActivityHandler); // Set defaults, then update using values stored in the Bundle. mAddressRequested = false; mAddressOutput = null; // Update values using data stored in the Bundle. updateValuesFromBundle(savedInstanceState); /** * ? ??? ? . * ?? ? . */ mBroadcastFramelayout = (FrameLayout) findViewById(R.id.realtimeBroadcastFragment); if (mBroadcastFramelayout != null) { mBroadcastFramelayout.setVisibility(View.GONE); } FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Bundle bundle; // check installation or bind to service VBroadcastServer serverInfo = LauncherSettings.getInstance(this).getServerInformation(); if (serverInfo == null || !Constants.VBROAD_INITIAL_PAGE.equals(serverInfo.getInitialServerPage())) { // ? ?. // ? Registration ? . LauncherSettings.getInstance(this).setServerInformation(null); LauncherSettings.getInstance(this).setIsCompletedSetup(false); // open user register fragment RegisterFragment registerFragment = new RegisterFragment(); bundle = new Bundle(); registerFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, registerFragment); } else { if (LauncherSettings.getInstance(this).isCompletedSetup() == false) { LauncherSettings.getInstance(this).setServerInformation(null); // open user register fragment RegisterFragment registerFragment = new RegisterFragment(); bundle = new Bundle(); registerFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, registerFragment); } else { // open main launcher fragment LauncherFragment launcherFragment = new LauncherFragment(); bundle = new Bundle(); launcherFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, launcherFragment); } } fragmentTransaction.commit(); // initialize iot interface. String collectServerAddress = null; if (serverInfo != null) { String apiServer = serverInfo.getApiServer(); if (StringUtils.isEmptyString(apiServer)) { collectServerAddress = null; } else { collectServerAddress = apiServer + Constants.API_COLLECTED_IOT_DATA_CONTEXT; } } IoTResultCodes resCode = IoTInterface.getInstance().initialize(this, LauncherSettings.getInstance(this).getDeviceID(), collectServerAddress); if (!resCode.equals(IoTResultCodes.SUCCESS)) { if (resCode.equals(IoTResultCodes.BIND_SERVICE_FAILED)) { Toast.makeText(getApplicationContext(), "Bind IoT Service failed!!!", Toast.LENGTH_SHORT).show(); } } }
From source file:org.tigase.mobile.chat.ChatHistoryFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.showChatsButton) { Intent chatListActivity = new Intent(getActivity(), ChatListActivity.class); this.getActivity().startActivityForResult(chatListActivity, TigaseMobileMessengerActivity.REQUEST_CHAT); } else if (item.getItemId() == R.id.closeChatButton) { layout.cancelEdit();/*from w ww .j a v a2 s . c o m*/ final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext()).getMultiJaxmpp() .get(chat.getSessionObject()); final ViewPager viewPager = ((TigaseMobileMessengerActivity) this.getActivity()).viewPager; final AbstractChatManager cm = jaxmpp.getModule(MessageModule.class).getChatManager(); try { viewPager.setCurrentItem(1); cm.close(chat); // this will be done by TigaseMessengerActiviy after receiving // ChatOpened event // viewPager.getAdapter().notifyDataSetChanged(); viewPager.setCurrentItem(1); if (DEBUG) Log.i(TAG, "Chat with " + chat.getJid() + " (" + chat.getId() + ") closed"); } catch (JaxmppException e) { Log.w(TAG, "Chat close problem!", e); } } else if (item.getItemId() == R.id.shareImageButton) { Log.v(TAG, "share selected for = " + chat.getJid().toString()); Intent pickerIntent = new Intent(Intent.ACTION_PICK); pickerIntent.setType("image/*"); pickerIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivityForResult(pickerIntent, TigaseMobileMessengerActivity.SELECT_FOR_SHARE); } else if (item.getItemId() == R.id.shareVideoButton) { Log.v(TAG, "share selected for = " + chat.getJid().toString()); Intent pickerIntent = new Intent(Intent.ACTION_PICK); pickerIntent.setType("video/*"); pickerIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivityForResult(pickerIntent, TigaseMobileMessengerActivity.SELECT_FOR_SHARE); } return true; }
From source file:com.groksolutions.grok.mobile.instance.InstanceListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (isMenuVisible() && item.getItemId() == R.id.menu_add_annotation) { // Get instance from context menu position AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); InstanceAnomalyChartData instance = (InstanceAnomalyChartData) getListAdapter().getItem(info.position); // Get timestamp from the selected bar on the anomaly chart AnomalyChartView view = (AnomalyChartView) info.targetView.findViewById(R.id.anomaly_chart_view); long selectedTimestamp = view.getSelectedTimestamp(); if (selectedTimestamp == -1) { // Should not happen Log.w(TAG, "Failed to get annotation timestamp from chart view. Using current time instead"); return true; }/*from ww w . j a va2 s . c o m*/ // Open "Add Annotation" activity Intent addAnnotation = new Intent(getActivity(), AddAnnotationActivity.class); addAnnotation.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); addAnnotation.putExtra(AddAnnotationActivity.EXTRA_INSTANCE_ID, instance.getId()); addAnnotation.putExtra(AddAnnotationActivity.EXTRA_TIMESTAMP, selectedTimestamp); getActivity().startActivity(addAnnotation); } return super.onContextItemSelected(item); }
From source file:com.trail.octo.UploadDocs.java
public boolean askCameraPermission() { check = false;/*from w ww .j a v a 2 s . c om*/ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(UploadDocs.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(UploadDocs.this, Manifest.permission.CAMERA)) { Log.e("Permission", "Explain here"); Toast.makeText(getApplicationContext(), "OCTO requires this Permission to upload Images!", Toast.LENGTH_LONG).show(); final Intent i = new Intent(); i.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + UploadDocs.this.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(i); // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. Log.e("Permission", "Requesting"); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, PERMISSION_REQUEST_CAMERA); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } else { return true; } return check; }
From source file:com.cerema.cloud2.syncadapter.FileSyncAdapter.java
/** * Notifies the user about a failed synchronization through the status notification bar *///from w ww. ja v a 2s . co m private void notifyFailedSynchronization() { NotificationCompat.Builder notificationBuilder = createNotificationBuilder(); boolean needsToUpdateCredentials = (mLastFailedResult != null && (mLastFailedResult.getCode() == ResultCode.UNAUTHORIZED || mLastFailedResult.isIdPRedirection())); if (needsToUpdateCredentials) { // let the user update credentials with one click Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount()); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND); notificationBuilder.setTicker(i18n(R.string.sync_fail_ticker_unauthorized)) .setContentTitle(i18n(R.string.sync_fail_ticker_unauthorized)) .setContentIntent(PendingIntent.getActivity(getContext(), (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT)) .setContentText(i18n(R.string.sync_fail_content_unauthorized, getAccount().name)); } else { notificationBuilder.setTicker(i18n(R.string.sync_fail_ticker)) .setContentTitle(i18n(R.string.sync_fail_ticker)) .setContentText(i18n(R.string.sync_fail_content, getAccount().name)); } showNotification(R.string.sync_fail_ticker, notificationBuilder); }
From source file:com.digitalarx.android.ui.activity.FileActivity.java
protected void requestCredentialsUpdate() { Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount()); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(updateAccountCredentials); }
From source file:com.trail.octo.UploadDocs.java
public boolean askGalleryPermission() { check = false;/*from w w w .j a v a2s. c o m*/ // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(UploadDocs.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(UploadDocs.this, Manifest.permission.READ_EXTERNAL_STORAGE)) { Log.e("Permission", "Explain here"); Toast.makeText(getApplicationContext(), "OCTO requires this Permission to upload Images!", Toast.LENGTH_LONG).show(); final Intent i = new Intent(); i.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + UploadDocs.this.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(i); // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. Log.e("Permission", "Requesting"); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, PERMISSION_REQUEST_READ_EXTERAL_STORAGE); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } else { return true; } return check; }
From source file:com.battlelancer.seriesguide.service.NotificationService.java
private void onNotify(final Cursor upcomingEpisodes, List<Integer> notifyPositions, long latestAirtime) { final Context context = getApplicationContext(); CharSequence tickerText;//from ww w.jav a 2 s . co m CharSequence contentTitle; CharSequence contentText; PendingIntent contentIntent; // base intent for task stack final Intent showsIntent = new Intent(context, ShowsActivity.class); showsIntent.putExtra(ShowsActivity.InitBundle.SELECTED_TAB, ShowsActivity.InitBundle.INDEX_TAB_UPCOMING); final int count = notifyPositions.size(); if (count == 1) { // notify in detail about one episode Timber.d("Notifying about 1 new episode"); upcomingEpisodes.moveToPosition(notifyPositions.get(0)); final String showTitle = upcomingEpisodes.getString(NotificationQuery.SHOW_TITLE); tickerText = getString(R.string.upcoming_show, showTitle); contentTitle = showTitle + " " + Utils.getEpisodeNumber(this, upcomingEpisodes.getInt(NotificationQuery.SEASON), upcomingEpisodes.getInt(NotificationQuery.NUMBER)); // "8:00 PM on Network" final String releaseTime = TimeTools.formatToLocalReleaseTime(this, TimeTools.getEpisodeReleaseTime( this, upcomingEpisodes.getLong(NotificationQuery.EPISODE_FIRST_RELEASE_MS))); final String network = upcomingEpisodes.getString(NotificationQuery.NETWORK); contentText = getString(R.string.upcoming_show_detailed, releaseTime, network); Intent episodeDetailsIntent = new Intent(context, EpisodesActivity.class); episodeDetailsIntent.putExtra(EpisodesActivity.InitBundle.EPISODE_TVDBID, upcomingEpisodes.getInt(NotificationQuery._ID)); episodeDetailsIntent.putExtra(KEY_EPISODE_CLEARED_TIME, latestAirtime); contentIntent = TaskStackBuilder.create(context).addNextIntent(showsIntent) .addNextIntent(episodeDetailsIntent) .getPendingIntent(REQUEST_CODE_SINGLE_EPISODE, PendingIntent.FLAG_CANCEL_CURRENT); } else { // notify about multiple episodes Timber.d("Notifying about " + count + " new episodes"); tickerText = getString(R.string.upcoming_episodes); contentTitle = getString(R.string.upcoming_episodes_number, count); contentText = getString(R.string.upcoming_display); contentIntent = TaskStackBuilder.create(context) .addNextIntent(showsIntent.putExtra(KEY_EPISODE_CLEARED_TIME, latestAirtime)) .getPendingIntent(REQUEST_CODE_MULTIPLE_EPISODES, PendingIntent.FLAG_CANCEL_CURRENT); } final NotificationCompat.Builder nb = new NotificationCompat.Builder(context); if (AndroidUtils.isJellyBeanOrHigher()) { Timber.d("Building rich notification (JB+)"); // JELLY BEAN and above if (count == 1) { // single episode upcomingEpisodes.moveToPosition(notifyPositions.get(0)); maybeSetPoster(context, nb, upcomingEpisodes.getString(NotificationQuery.POSTER)); final String episodeTitle = upcomingEpisodes.getString(NotificationQuery.TITLE); final String episodeSummary = upcomingEpisodes.getString(NotificationQuery.OVERVIEW); final SpannableStringBuilder bigText = new SpannableStringBuilder(); bigText.append(TextUtils.isEmpty(episodeTitle) ? "" : episodeTitle); bigText.setSpan(new StyleSpan(Typeface.BOLD), 0, bigText.length(), 0); bigText.append("\n"); bigText.append(TextUtils.isEmpty(episodeSummary) ? "" : episodeSummary); nb.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText).setSummaryText(contentText)); // Action button to check in Intent checkInActionIntent = new Intent(context, QuickCheckInActivity.class); checkInActionIntent.putExtra(QuickCheckInActivity.InitBundle.EPISODE_TVDBID, upcomingEpisodes.getInt(NotificationQuery._ID)); checkInActionIntent .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); PendingIntent checkInIntent = PendingIntent.getActivity(context, REQUEST_CODE_ACTION_CHECKIN, checkInActionIntent, PendingIntent.FLAG_CANCEL_CURRENT); nb.addAction(R.drawable.ic_action_checkin, getString(R.string.checkin), checkInIntent); } else { // multiple episodes NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); // display at most the first five for (int displayIndex = 0; displayIndex < Math.min(count, 5); displayIndex++) { if (!upcomingEpisodes.moveToPosition(notifyPositions.get(displayIndex))) { // could not go to the desired position (testing just in case) break; } final SpannableStringBuilder lineText = new SpannableStringBuilder(); // show title String showTitle = upcomingEpisodes.getString(NotificationQuery.SHOW_TITLE); lineText.append(TextUtils.isEmpty(showTitle) ? "" : showTitle); lineText.setSpan(new StyleSpan(Typeface.BOLD), 0, lineText.length(), 0); lineText.append(" "); // "8:00 PM on Network" String releaseTime = TimeTools.formatToLocalReleaseTime(this, TimeTools.getEpisodeReleaseTime( this, upcomingEpisodes.getLong(NotificationQuery.EPISODE_FIRST_RELEASE_MS))); String network = upcomingEpisodes.getString(NotificationQuery.NETWORK); lineText.append(getString(R.string.upcoming_show_detailed, releaseTime, network)); inboxStyle.addLine(lineText); } // tell if we could not display all episodes if (count > 5) { inboxStyle.setSummaryText(getString(R.string.more, count - 5)); } nb.setStyle(inboxStyle); nb.setContentInfo(String.valueOf(count)); } } else { // ICS and below if (count == 1) { // single episode upcomingEpisodes.moveToPosition(notifyPositions.get(0)); maybeSetPoster(context, nb, upcomingEpisodes.getString(NotificationQuery.POSTER)); } } // notification sound final String ringtoneUri = NotificationSettings.getNotificationsRingtone(context); // If the string is empty, the user chose silent... if (ringtoneUri.length() != 0) { // ...otherwise set the specified ringtone Timber.d("Notification has sound"); nb.setSound(Uri.parse(ringtoneUri)); } // vibration if (NotificationSettings.isNotificationVibrating(context)) { Timber.d("Notification vibrates"); nb.setVibrate(VIBRATION_PATTERN); } nb.setDefaults(Notification.DEFAULT_LIGHTS); nb.setWhen(System.currentTimeMillis()); nb.setAutoCancel(true); nb.setTicker(tickerText); nb.setContentTitle(contentTitle); nb.setContentText(contentText); nb.setContentIntent(contentIntent); nb.setSmallIcon(R.drawable.ic_notification); nb.setColor(getResources().getColor(R.color.accent_primary)); nb.setPriority(NotificationCompat.PRIORITY_DEFAULT); nb.setCategory(NotificationCompat.CATEGORY_EVENT); Timber.d("Setting delete intent with episode time: " + latestAirtime); Intent i = new Intent(this, NotificationService.class); i.putExtra(KEY_EPISODE_CLEARED_TIME, latestAirtime); PendingIntent deleteIntent = PendingIntent.getService(this, REQUEST_CODE_DELETE_INTENT, i, PendingIntent.FLAG_CANCEL_CURRENT); nb.setDeleteIntent(deleteIntent); // build the notification Notification notification = nb.build(); // use string resource id, always unique within app final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(R.string.upcoming_show, notification); }
From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { int id = item.getItemId(); if (id == R.id.nav_marakez) { Intent intent = new Intent(this, PageMarakez.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); //intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); finish();//from ww w . ja v a 2 s. co m startActivity(intent); } else if (id == R.id.nav_profile) { Intent intent = new Intent(this, PageVirayesh.class); finish(); startActivity(intent); } else if (id == R.id.nav_login) { Intent intent = new Intent(this, PageLogin.class); finish(); startActivity(intent); } else if (id == R.id.nav_moshaverin) { Intent intent = new Intent(this, PageMoshaverin.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); finish(); startActivity(intent); } else if (id == R.id.nav_porseshha) { Intent intent = new Intent(this, PagePorseshha.class); finish(); startActivity(intent); } else if (id == R.id.nav_logout) { Intent intent = new Intent(this, PageLogout.class); finish(); startActivity(intent); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.END); return true; }