List of usage examples for android.app Notification PRIORITY_MAX
int PRIORITY_MAX
To view the source code for android.app Notification PRIORITY_MAX.
Click Source Link
From source file:com.conferenceengineer.android.iosched.service.SessionAlarmService.java
private void notifySession(final long sessionStart, final long sessionEnd, final long alarmOffset) { long currentTime; if (sessionStart < (currentTime = UIUtils.getCurrentTime(this))) return;//from www . j av a2 s . c om // Avoid repeated notifications. if (alarmOffset == UNDEFINED_ALARM_OFFSET && UIUtils.isNotificationFiredForBlock(this, ScheduleContract.Blocks.generateBlockId(sessionStart, sessionEnd))) { return; } final ContentResolver cr = getContentResolver(); final Uri starredBlockUri = ScheduleContract.Blocks .buildStarredSessionsUri(ScheduleContract.Blocks.generateBlockId(sessionStart, sessionEnd)); Cursor c = cr.query(starredBlockUri, SessionDetailQuery.PROJECTION, null, null, null); int starredCount = 0; ArrayList<String> starredSessionTitles = new ArrayList<String>(); ArrayList<String> starredSessionRoomIds = new ArrayList<String>(); String sessionId = null; // needed to get session track icon while (c.moveToNext()) { sessionId = c.getString(SessionDetailQuery.SESSION_ID); starredCount = c.getInt(SessionDetailQuery.NUM_STARRED_SESSIONS); starredSessionTitles.add(c.getString(SessionDetailQuery.SESSION_TITLE)); starredSessionRoomIds.add(c.getString(SessionDetailQuery.ROOM_ID)); } if (starredCount < 1) { return; } // Generates the pending intent which gets fired when the user taps on the notification. // NOTE: Use TaskStackBuilder to comply with Android's design guidelines // related to navigation from notifications. PendingIntent pi = TaskStackBuilder.create(this).addNextIntent(new Intent(this, HomeActivity.class)) .addNextIntent(new Intent(Intent.ACTION_VIEW, starredBlockUri)) .getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); final Resources res = getResources(); String contentText; int minutesLeft = (int) (sessionStart - currentTime + 59000) / 60000; if (minutesLeft < 1) { minutesLeft = 1; } if (starredCount == 1) { contentText = res.getString(R.string.session_notification_text_1, minutesLeft); } else { contentText = res.getQuantityString(R.plurals.session_notification_text, starredCount - 1, minutesLeft, starredCount - 1); } NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this) .setContentTitle(starredSessionTitles.get(0)).setContentText(contentText) .setTicker(res.getQuantityString(R.plurals.session_notification_ticker, starredCount, starredCount)) .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(SessionAlarmService.NOTIFICATION_ARGB_COLOR, SessionAlarmService.NOTIFICATION_LED_ON_MS, SessionAlarmService.NOTIFICATION_LED_OFF_MS) .setSmallIcon(R.drawable.conference_ic_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true); if (starredCount == 1) { // get the track icon to show as the notification big picture Uri tracksUri = ScheduleContract.Sessions.buildTracksDirUri(sessionId); Cursor tracksCursor = cr.query(tracksUri, SessionTrackQuery.PROJECTION, null, null, null); if (tracksCursor.moveToFirst()) { String trackName = tracksCursor.getString(SessionTrackQuery.TRACK_NAME); int trackColour = tracksCursor.getInt(SessionTrackQuery.TRACK_COLOR); Bitmap trackIcon = UIUtils.getTrackIconSync(getApplicationContext(), trackName, trackColour); if (trackIcon != null) { notifBuilder.setLargeIcon(trackIcon); } } } if (minutesLeft > 5) { notifBuilder.addAction(R.drawable.ic_alarm_holo_dark, String.format(res.getString(R.string.snooze_x_min), 5), createSnoozeIntent(sessionStart, sessionEnd, 5)); } NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(res.getQuantityString(R.plurals.session_notification_title, starredCount, minutesLeft, starredCount)); // Adds starred sessions starting at this time block to the notification. for (int i = 0; i < starredCount; i++) { richNotification.addLine(starredSessionTitles.get(i)); } NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, richNotification.build()); }
From source file:net.olejon.spotcommander.WebViewActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Google API client mGoogleApiClient = new GoogleApiClient.Builder(mContext).addApiIfAvailable(Wearable.API).build(); // Allow landscape? if (!mTools.allowLandscape()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Hide status bar? if (mTools.getDefaultSharedPreferencesBoolean("HIDE_STATUS_BAR")) getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Power manager final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "wakeLock"); // Settings/*from w w w. j a v a 2 s. c om*/ mTools.setSharedPreferencesBoolean("CAN_CLOSE_COVER", false); // Current network mCurrentNetwork = mTools.getCurrentNetwork(); // Computer final long computerId = mTools.getSharedPreferencesLong("LAST_COMPUTER_ID"); final String[] computer = mTools.getComputer(computerId); final String uri = computer[0]; final String username = computer[1]; final String password = computer[2]; // Layout setContentView(R.layout.activity_webview); // Status bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mStatusBarPrimaryColor = getWindow().getStatusBarColor(); mStatusBarCoverArtColor = mStatusBarPrimaryColor; } // Notification mPersistentNotificationIsSupported = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); if (mPersistentNotificationIsSupported) { final Intent launchActivityIntent = new Intent(mContext, MainActivity.class); launchActivityIntent.setAction("android.intent.action.MAIN"); launchActivityIntent.addCategory("android.intent.category.LAUNCHER"); mLaunchActivityPendingIntent = PendingIntent.getActivity(mContext, 0, launchActivityIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent hideIntent = new Intent(mContext, RemoteControlIntentService.class); hideIntent.setAction("hide_notification"); hideIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mHidePendingIntent = PendingIntent.getService(mContext, 0, hideIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent previousIntent = new Intent(mContext, RemoteControlIntentService.class); previousIntent.setAction("previous"); previousIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mPreviousPendingIntent = PendingIntent.getService(mContext, 0, previousIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent playPauseIntent = new Intent(mContext, RemoteControlIntentService.class); playPauseIntent.setAction("play_pause"); playPauseIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mPlayPausePendingIntent = PendingIntent.getService(mContext, 0, playPauseIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent nextIntent = new Intent(mContext, RemoteControlIntentService.class); nextIntent.setAction("next"); nextIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mNextPendingIntent = PendingIntent.getService(mContext, 0, nextIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent volumeDownIntent = new Intent(mContext, RemoteControlIntentService.class); volumeDownIntent.setAction("adjust_spotify_volume_down"); volumeDownIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mVolumeDownPendingIntent = PendingIntent.getService(mContext, 0, volumeDownIntent, PendingIntent.FLAG_CANCEL_CURRENT); final Intent volumeUpIntent = new Intent(mContext, RemoteControlIntentService.class); volumeUpIntent.setAction("adjust_spotify_volume_up"); volumeUpIntent.putExtra(RemoteControlIntentService.REMOTE_CONTROL_INTENT_SERVICE_EXTRA, computerId); mVolumeUpPendingIntent = PendingIntent.getService(mContext, 0, volumeUpIntent, PendingIntent.FLAG_CANCEL_CURRENT); mNotificationManager = NotificationManagerCompat.from(mContext); mNotificationBuilder = new NotificationCompat.Builder(mContext); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) mNotificationBuilder.setPriority(Notification.PRIORITY_MAX); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mNotificationBuilder.setVisibility(Notification.VISIBILITY_PUBLIC); mNotificationBuilder.setCategory(Notification.CATEGORY_TRANSPORT); } } // Web view mWebView = (WebView) findViewById(R.id.webview_webview); mWebView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.background)); mWebView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY); mWebView.setWebViewClient(new WebViewClient() { @SuppressWarnings("deprecation") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url != null && !url.contains(uri) && !url.contains("olejon.net/code/spotcommander/api/1/spotify/") && !url.contains("accounts.spotify.com/") && !url.contains("facebook.com/")) { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } return false; } @Override public void onReceivedHttpAuthRequest(WebView view, @NonNull HttpAuthHandler handler, String host, String realm) { if (handler.useHttpAuthUsernamePassword()) { handler.proceed(username, password); } else { handler.cancel(); mWebView.stopLoading(); mTools.showToast(getString(R.string.webview_authentication_failed), 1); mTools.navigateUp(mActivity); } } @Override public void onReceivedError(WebView view, WebResourceRequest webResourceRequest, WebResourceError webResourceError) { mWebView.stopLoading(); mTools.showToast(getString(R.string.webview_error), 1); mTools.navigateUp(mActivity); } @Override public void onReceivedSslError(WebView view, @NonNull SslErrorHandler handler, SslError error) { handler.cancel(); mWebView.stopLoading(); new MaterialDialog.Builder(mContext).title(R.string.webview_dialog_ssl_error_title) .content(getString(R.string.webview_dialog_ssl_error_message)) .positiveText(R.string.webview_dialog_ssl_error_positive_button) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { finish(); } }).contentColorRes(R.color.black).show(); } }); // User agent mProjectVersionName = mTools.getProjectVersionName(); final String uaAppend1 = (!username.equals("") && !password.equals("")) ? "AUTHENTICATION_ENABLED " : ""; final String uaAppend2 = (mTools.getSharedPreferencesBoolean("WEAR_CONNECTED")) ? "WEAR_CONNECTED " : ""; final String uaAppend3 = (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT && !mTools.getDefaultSharedPreferencesBoolean("HARDWARE_ACCELERATED_ANIMATIONS")) ? "DISABLE_CSSTRANSITIONS DISABLE_CSSTRANSFORMS3D " : ""; // Web settings final WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(false); webSettings.setUserAgentString(getString(R.string.webview_user_agent, webSettings.getUserAgentString(), mProjectVersionName, uaAppend1, uaAppend2, uaAppend3)); // Load app if (savedInstanceState != null) { mWebView.restoreState(savedInstanceState); } else { mWebView.loadUrl(uri); } // JavaScript interface mWebView.addJavascriptInterface(new JavaScriptInterface(), "Android"); }
From source file:com.learnit.LearnIt.data_types.NotificationBuilder.java
private static boolean CreateNotifications(ArrayList<ArticleWordId> randWords, Context context, int wayToLearn) { ArrayList<Intent> intents = new ArrayList<Intent>(); ArrayList<Integer> ids = new ArrayList<Integer>(); ArrayList<String> words = new ArrayList<String>(); ArrayList<String> articles = new ArrayList<String>(); ArrayList<String> translations = new ArrayList<String>(); ArrayList<String> prefixes = new ArrayList<String>(); ArrayList<Integer> directionsOfTrans = new ArrayList<Integer>(); ArrayList<Integer> typesOfHomeworks = new ArrayList<Integer>(); ArrayList<Class> classes = new ArrayList<Class>(); for (ArticleWordId struct : randWords) { int homeworkActivityType = getHomeworkType(wayToLearn, struct.article); int directionOfTranslation = getDirectionOfTranslation(context, sp, homeworkActivityType); ids.add(struct.id + idModificator); words.add(struct.word);/*from w w w . j a v a2 s . co m*/ articles.add(struct.article); translations.add(struct.translation); prefixes.add(struct.prefix); intents.add(getIntentFromHomeworkType(context, homeworkActivityType)); typesOfHomeworks.add(homeworkActivityType); classes.add(getStackTypeFromHomeworkType(homeworkActivityType)); directionsOfTrans.add(directionOfTranslation); } for (int i = 0; i < intents.size(); ++i) { Intent intent = intents.get(i); intent.putExtra(IDS_TAG, ids); intent.putExtra(WORDS_TAG, words); intent.putExtra(TRANSLATIONS_TAG, translations); intent.putExtra(ARTICLES_TAG, articles); intent.putExtra(PREFIXES_TAG, prefixes); intent.putExtra(DIRECTIONS_OF_TRANS_TAG, directionsOfTrans); intent.putExtra(HOMEWORK_TYPE_TAG, typesOfHomeworks); intent.putExtra(CURRENT_NOTIFICATION_INDEX, i); intent.setAction(ids.get(i) + " " + words.get(i) + " " + System.currentTimeMillis()); NotificationCompat.Builder mBuilder; mBuilder = getBuilder(context, directionsOfTrans.get(i), randWords.get(i)); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); stackBuilder.addParentStack(classes.get(i)); stackBuilder.addNextIntent(intent); PendingIntent pendInt = PendingIntent.getActivity(context, ids.get(i), intent, PendingIntent.FLAG_UPDATE_CURRENT); if (null != mBuilder) { mBuilder.setSmallIcon(Utils.getIconForWordNumber(i + 1)); mBuilder.setContentIntent(pendInt); mBuilder.setPriority(Notification.PRIORITY_MAX); mBuilder.setOngoing(true); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(ids.get(i), mBuilder.build()); currentIds = currentIds + ids.get(i) + " "; } else return false; } return true; }
From source file:com.gdgdevfest.android.apps.devfestbcn.service.SessionAlarmService.java
private void notifySession(final long sessionStart, final long sessionEnd, final long alarmOffset) { long currentTime; if (sessionStart < (currentTime = UIUtils.getCurrentTime(this))) return;//from w w w.ja v a 2 s . co m // Avoid repeated notifications. if (alarmOffset == UNDEFINED_ALARM_OFFSET && UIUtils.isNotificationFiredForBlock(this, ScheduleContract.Blocks.generateBlockId(sessionStart, sessionEnd))) { return; } final ContentResolver cr = getContentResolver(); final Uri starredBlockUri = ScheduleContract.Blocks .buildStarredSessionsUri(ScheduleContract.Blocks.generateBlockId(sessionStart, sessionEnd)); Cursor c = cr.query(starredBlockUri, SessionDetailQuery.PROJECTION, null, null, null); int starredCount = 0; ArrayList<String> starredSessionTitles = new ArrayList<String>(); ArrayList<String> starredSessionRoomIds = new ArrayList<String>(); String sessionId = null; // needed to get session track icon while (c.moveToNext()) { sessionId = c.getString(SessionDetailQuery.SESSION_ID); starredCount = c.getInt(SessionDetailQuery.NUM_STARRED_SESSIONS); starredSessionTitles.add(c.getString(SessionDetailQuery.SESSION_TITLE)); starredSessionRoomIds.add(c.getString(SessionDetailQuery.ROOM_ID)); } if (starredCount < 1) { return; } // Generates the pending intent which gets fired when the user taps on the notification. // NOTE: Use TaskStackBuilder to comply with Android's design guidelines // related to navigation from notifications. PendingIntent pi = TaskStackBuilder.create(this).addNextIntent(new Intent(this, HomeActivity.class)) .addNextIntent(new Intent(Intent.ACTION_VIEW, starredBlockUri)) .getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); final Resources res = getResources(); String contentText; int minutesLeft = (int) (sessionStart - currentTime + 59000) / 60000; if (minutesLeft < 1) { minutesLeft = 1; } if (starredCount == 1) { contentText = res.getString(R.string.session_notification_text_1, minutesLeft); } else { contentText = res.getQuantityString(R.plurals.session_notification_text, starredCount - 1, minutesLeft, starredCount - 1); } NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this) .setContentTitle(starredSessionTitles.get(0)).setContentText(contentText) .setTicker(res.getQuantityString(R.plurals.session_notification_ticker, starredCount, starredCount)) .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(SessionAlarmService.NOTIFICATION_ARGB_COLOR, SessionAlarmService.NOTIFICATION_LED_ON_MS, SessionAlarmService.NOTIFICATION_LED_OFF_MS) .setSmallIcon(R.drawable.ic_stat_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true); if (starredCount == 1) { // get the track icon to show as the notification big picture Uri tracksUri = ScheduleContract.Sessions.buildTracksDirUri(sessionId); Cursor tracksCursor = cr.query(tracksUri, SessionTrackQuery.PROJECTION, null, null, null); if (tracksCursor.moveToFirst()) { String trackName = tracksCursor.getString(SessionTrackQuery.TRACK_NAME); int trackColour = tracksCursor.getInt(SessionTrackQuery.TRACK_COLOR); Bitmap trackIcon = UIUtils.getTrackIconSync(getApplicationContext(), trackName, trackColour); if (trackIcon != null) { notifBuilder.setLargeIcon(trackIcon); } } } if (minutesLeft > 5) { notifBuilder.addAction(R.drawable.ic_alarm_holo_dark, String.format(res.getString(R.string.snooze_x_min), 5), createSnoozeIntent(sessionStart, sessionEnd, 5)); } if (starredCount == 1 && PrefUtils.isAttendeeAtVenue(this)) { notifBuilder.addAction(R.drawable.ic_map_holo_dark, res.getString(R.string.title_map), createRoomMapIntent(starredSessionRoomIds.get(0))); } NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(res.getQuantityString(R.plurals.session_notification_title, starredCount, minutesLeft, starredCount)); // Adds starred sessions starting at this time block to the notification. for (int i = 0; i < starredCount; i++) { richNotification.addLine(starredSessionTitles.get(i)); } NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, richNotification.build()); }
From source file:org.messic.android.smartphone.notifications.MessicPlayerNotification.java
private void createNotification() { if (this.notification != null) { return;// w w w . j a v a2 s. c om } mNotificationManager = (NotificationManager) this.service.getSystemService(Context.NOTIFICATION_SERVICE); RemoteViews smallContentView = new RemoteViews(this.service.getPackageName(), R.layout.notification_small); RemoteViews bigContentView = new RemoteViews(this.service.getPackageName(), R.layout.notification_big); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this.service); mBuilder.setSmallIcon(R.mipmap.ic_launcher); mBuilder.setContentTitle("title"); mBuilder.setPriority(Notification.PRIORITY_MAX); mBuilder.setContent(bigContentView); Notification n = mBuilder.build(); n.contentView = smallContentView; n.bigContentView = bigContentView; Intent intentClose = new Intent(ACTION_CLOSE); PendingIntent pintentClose = PendingIntent.getBroadcast(this.service, 0, intentClose, 0); bigContentView.setOnClickPendingIntent(R.id.bignotification_ivclose, pintentClose); smallContentView.setOnClickPendingIntent(R.id.bignotification_ivclose, pintentClose); Intent intentBack = new Intent(ACTION_BACK); PendingIntent pintentBack = PendingIntent.getBroadcast(this.service, 0, intentBack, 0); bigContentView.setOnClickPendingIntent(R.id.bignotification_ivback, pintentBack); smallContentView.setOnClickPendingIntent(R.id.bignotification_ivback, pintentBack); Intent intentPlay = new Intent(ACTION_PLAY); PendingIntent pintentPlay = PendingIntent.getBroadcast(this.service, 0, intentPlay, 0); bigContentView.setOnClickPendingIntent(R.id.bignotification_ivplay, pintentPlay); smallContentView.setOnClickPendingIntent(R.id.bignotification_ivplay, pintentPlay); Intent intentPause = new Intent(ACTION_PAUSE); PendingIntent pintentPause = PendingIntent.getBroadcast(this.service, 0, intentPause, 0); bigContentView.setOnClickPendingIntent(R.id.bignotification_ivpause, pintentPause); smallContentView.setOnClickPendingIntent(R.id.bignotification_ivpause, pintentPause); Intent intentNext = new Intent(ACTION_NEXT); PendingIntent pintentNext = PendingIntent.getBroadcast(this.service, 0, intentNext, 0); bigContentView.setOnClickPendingIntent(R.id.bignotification_ivnext, pintentNext); smallContentView.setOnClickPendingIntent(R.id.bignotification_ivnext, pintentNext); Intent intentAlbum = new Intent(ACTION_ALBUM); PendingIntent pintentAlbum = PendingIntent.getBroadcast(this.service, 0, intentAlbum, PendingIntent.FLAG_CANCEL_CURRENT); bigContentView.setOnClickPendingIntent(R.id.bignotification_ivcurrent_cover, pintentAlbum); bigContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_author, pintentAlbum); bigContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_song, pintentAlbum); smallContentView.setOnClickPendingIntent(R.id.bignotification_ivcurrent_cover, pintentAlbum); smallContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_author, pintentAlbum); smallContentView.setOnClickPendingIntent(R.id.bignotification_tvcurrent_song, pintentAlbum); this.notification = n; this.service.startForeground(ONGOING_NOTIFICATION_ID, notification); this.registerBroadcastActions(); }
From source file:uk.bowdlerize.service.CensorCensusService.java
private void performProbe(final Intent intent) { Intent newIntent = new Intent(); newIntent.setAction(ProgressFragment.ORG_BROADCAST); newIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.TALKING_TO_ISP); sendBroadcast(newIntent);/*from w ww.j a v a 2 s . co m*/ //If this is user submitted send it up for further research if (intent.getBooleanExtra("local", false)) { new Thread() { public void run() { try { api.submitURL(intent.getStringExtra("url")); } catch (Exception e) { e.printStackTrace(); } } }.start(); } mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle(getString(R.string.notifTitle) + " - " + getString(R.string.notifURLRecv)) .addLine(getString(R.string.notifNewURL)).addLine(getString(R.string.notifSanityCheck)) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))) .setSmallIcon(R.drawable.ic_stat_in_progress) .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_ooni_large)) .setPriority(Notification.PRIORITY_MAX) .setTicker(getString(R.string.notifTitle) + " - " + getString(R.string.notifURLRecv)) .setAutoCancel(false); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); new Thread(new Runnable() { @Override public void run() { String url = intent.getStringExtra("url"); String hash = intent.getStringExtra("hash"); //Pair<Boolean,Integer> wasCensored; CensorPayload censorPayload; String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifCheckURL)) .addLine(getString(R.string.notifStartAt) + " " + currentDateTimeString) .addLine(getString(R.string.notifCheckURL) + ".....").addLine("MD5: " + hash) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))); mBuilder.setProgress(2, 1, true); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); try { if (null == url) throw new NullPointerException(); //Do the actual check censorPayload = checkURL(url); //We're complete - update the time currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); //Update our local stats setCounts(censorPayload.wasCensored()); censorPayload.MD5 = hash; Intent ORGCensorIntent = new Intent(); ORGCensorIntent.setAction(ProgressFragment.ORG_BROADCAST); ORGCensorIntent.putExtra("url", url); ORGCensorIntent.putExtra("hash", hash); ORGCensorIntent.putExtra("date", currentDateTimeString); if (censorPayload.wasCensored()) { ORGCensorIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.BLOCKED); ORGCensorIntent.putExtra(ResultsGrid.INTENT_FILTER, LocalCache.RESULT_BLOCKED); mBuilder.setTicker(getString(R.string.notifFoundBlock)); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifWaiting)) .addLine(getString(R.string.notifLastChk) + ": " + currentDateTimeString) .addLine(getString(R.string.notifLastURLBlocked)) .addLine("MD5: " + intent.getStringExtra("hash")) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock)) ); mBuilder.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_ooni_large_censored)); } else { ORGCensorIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.OK); ORGCensorIntent.putExtra(ResultsGrid.INTENT_FILTER, LocalCache.RESULT_OK); mBuilder.setTicker( getString(R.string.notifTitle) + " - " + getString(R.string.notifLastChkNotBlock)); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifWaiting)) .addLine(getString(R.string.notifLastChk) + ": " + currentDateTimeString) .addLine(getString(R.string.notifLastChkNotBlock)) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))); } sendBroadcast(ORGCensorIntent); } catch (Exception e) { e.printStackTrace(); //We're complete - update the time currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date()); mBuilder.setStyle(new NotificationCompat.InboxStyle() .setBigContentTitle( getString(R.string.notifTitle) + " - " + getString(R.string.notifError)) .addLine(getString(R.string.notifLastChk) + ": " + currentDateTimeString) .addLine(getString(R.string.notifException)) .setSummaryText(Integer.toString(checkedCount) + " " + getString(R.string.notifChecked) + " / " + Integer.toString(censoredCount) + " " + getString(R.string.notifPossBlock))); censorPayload = null; Intent newIntent = new Intent(); newIntent.setAction(ProgressFragment.ORG_BROADCAST); newIntent.putExtra(ProgressFragment.ORG_BROADCAST, ProgressFragment.NO_URLS); sendBroadcast(newIntent); } mBuilder.setProgress(0, 0, false); mBuilder.setSmallIcon(R.drawable.ic_stat_waiting); mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build()); //Send the details back regardless (will chew DB space but will give a clearer picture) //api.notifyBackEnd(url,"",wasCensored, intent.getStringExtra("isp"), intent.getStringExtra("sim")); api.notifyBackEnd(censorPayload); /*if(sendtoORG) notifyOONIDirectly(url,wasCensored, intent.getStringExtra("isp"), intent.getStringExtra("sim")); */ onProbeFinish(); } }).start(); }
From source file:com.perm.DoomPlay.PlayingService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private Notification createJellyBeanNotif() { RemoteViews views = getNotifViews(R.layout.notif_jelly); Notification notification = createNotification(); views.setTextViewText(R.id.textNotifCount, String.valueOf(indexCurrentTrack + 1) + "/" + String.valueOf(audios.size())); notification.bigContentView = views; notification.priority = Notification.PRIORITY_MAX; return notification; }
From source file:com.android.deskclock.data.TimerNotificationBuilderN.java
@Override public Notification buildHeadsUp(Context context, List<Timer> expired) { final Timer timer = expired.get(0); // First action intent is to reset all timers. final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_stop_24dp); final Intent reset = TimerService.createResetExpiredTimersIntent(context); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); // Generate some descriptive text, a title, and an action name based on the timer count. final CharSequence stateText; final int count = expired.size(); final List<Notification.Action> actions = new ArrayList<>(2); if (count == 1) { final String label = timer.getLabel(); if (TextUtils.isEmpty(label)) { stateText = context.getString(R.string.timer_times_up); } else {/*from w w w. j av a2s . com*/ stateText = label; } // Left button: Reset single timer final CharSequence title1 = context.getString(R.string.timer_stop); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right button: Add minute final Intent addTime = TimerService.createAddMinuteTimerIntent(context, timer.getId()); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addTime); final Icon icon2 = Icon.createWithResource(context, R.drawable.ic_add_24dp); final CharSequence title2 = context.getString(R.string.timer_plus_1_min); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } else { stateText = context.getString(R.string.timer_multi_times_up, count); // Left button: Reset all timers final CharSequence title1 = context.getString(R.string.timer_stop_all); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); } final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final RemoteViews contentView = new RemoteViews(pname, R.layout.chronometer_notif_content); contentView.setChronometerCountDown(R.id.chronometer, true); contentView.setChronometer(R.id.chronometer, base, null, true); contentView.setTextViewText(R.id.state, stateText); // Content intent shows the timer full screen when clicked. final Intent content = new Intent(context, ExpiredTimersActivity.class); final PendingIntent contentIntent = Utils.pendingActivityIntent(context, content); // Full screen intent has flags so it is different than the content intent. final Intent fullScreen = new Intent(context, ExpiredTimersActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); final PendingIntent pendingFullScreen = Utils.pendingActivityIntent(context, fullScreen); return new Notification.Builder(context).setOngoing(true).setLocalOnly(true).setShowWhen(false) .setAutoCancel(false).setContentIntent(contentIntent).setCustomContentView(contentView) .setPriority(Notification.PRIORITY_MAX).setDefaults(Notification.DEFAULT_LIGHTS) .setColor(ContextCompat.getColor(context, R.color.default_background)) .setSmallIcon(R.drawable.stat_notify_timer).setFullScreenIntent(pendingFullScreen, true) .setStyle(new Notification.DecoratedCustomViewStyle()) .setActions(actions.toArray(new Notification.Action[actions.size()])).build(); }
From source file:com.wizardsofm.deskclock.data.TimerNotificationBuilderN.java
@Override public Notification buildHeadsUp(Context context, List<Timer> expired) { final Timer timer = expired.get(0); // First action intent is to reset all timers. final Icon icon1 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_stop_24dp); final Intent reset = TimerService.createResetExpiredTimersIntent(context); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); // Generate some descriptive text, a title, and an action name based on the timer count. final CharSequence stateText; final int count = expired.size(); final List<Notification.Action> actions = new ArrayList<>(2); if (count == 1) { final String label = timer.getLabel(); if (TextUtils.isEmpty(label)) { stateText = context.getString(com.wizardsofm.deskclock.R.string.timer_times_up); } else {/* w ww .jav a2s .c o m*/ stateText = label; } // Left button: Reset single timer final CharSequence title1 = context.getString(com.wizardsofm.deskclock.R.string.timer_stop); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right button: Add minute final Intent addTime = TimerService.createAddMinuteTimerIntent(context, timer.getId()); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addTime); final Icon icon2 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_add_24dp); final CharSequence title2 = context.getString(com.wizardsofm.deskclock.R.string.timer_plus_1_min); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } else { stateText = context.getString(com.wizardsofm.deskclock.R.string.timer_multi_times_up, count); // Left button: Reset all timers final CharSequence title1 = context.getString(com.wizardsofm.deskclock.R.string.timer_stop_all); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); } final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final RemoteViews contentView = new RemoteViews(pname, com.wizardsofm.deskclock.R.layout.chronometer_notif_content); contentView.setChronometerCountDown(com.wizardsofm.deskclock.R.id.chronometer, true); contentView.setChronometer(com.wizardsofm.deskclock.R.id.chronometer, base, null, true); contentView.setTextViewText(com.wizardsofm.deskclock.R.id.state, stateText); // Content intent shows the timer full screen when clicked. final Intent content = new Intent(context, ExpiredTimersActivity.class); final PendingIntent contentIntent = Utils.pendingActivityIntent(context, content); // Full screen intent has flags so it is different than the content intent. final Intent fullScreen = new Intent(context, ExpiredTimersActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); final PendingIntent pendingFullScreen = Utils.pendingActivityIntent(context, fullScreen); return new Notification.Builder(context).setOngoing(true).setLocalOnly(true).setShowWhen(false) .setAutoCancel(false).setContentIntent(contentIntent).setCustomContentView(contentView) .setPriority(Notification.PRIORITY_MAX).setDefaults(Notification.DEFAULT_LIGHTS) .setColor(ContextCompat.getColor(context, com.wizardsofm.deskclock.R.color.default_background)) .setSmallIcon(com.wizardsofm.deskclock.R.drawable.stat_notify_timer) .setFullScreenIntent(pendingFullScreen, true).setStyle(new Notification.DecoratedCustomViewStyle()) .setActions(actions.toArray(new Notification.Action[actions.size()])).build(); }
From source file:com.orpheusdroid.screenrecorder.RecorderService.java
private NotificationCompat.Builder createNotification(NotificationCompat.Action action) { Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); Intent recordStopIntent = new Intent(this, RecorderService.class); recordStopIntent.setAction(Const.SCREEN_RECORDING_STOP); PendingIntent precordStopIntent = PendingIntent.getService(this, 0, recordStopIntent, 0); Intent UIIntent = new Intent(this, MainActivity.class); PendingIntent notificationContentIntent = PendingIntent.getActivity(this, 0, UIIntent, 0); NotificationCompat.Builder notification = new NotificationCompat.Builder(this) .setContentTitle(getResources().getString(R.string.screen_recording_notification_title)) .setTicker(getResources().getString(R.string.screen_recording_notification_title)) .setSmallIcon(R.drawable.ic_notification) .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false)).setUsesChronometer(true) .setOngoing(true).setContentIntent(notificationContentIntent).setPriority(Notification.PRIORITY_MAX) .addAction(R.drawable.ic_notification_stop, getResources().getString(R.string.screen_recording_notification_action_stop), precordStopIntent);/* w w w. java2 s. c o m*/ if (action != null) notification.addAction(action); return notification; }