List of usage examples for android.content Context NOTIFICATION_SERVICE
String NOTIFICATION_SERVICE
To view the source code for android.content Context NOTIFICATION_SERVICE.
Click Source Link
From source file:ru.orangesoftware.financisto2.export.flowzr.FlowzrSyncEngine.java
public static void builAndRun(Context context) { final FlowzrSyncActivity fa = FlowzrSyncActivity.getMySelf(); if (fa == null) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(context, FlowzrSyncActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Builder mNotifyBuilder = new NotificationCompat.Builder(context); mNotifyBuilder.setContentIntent(contentIntent).setSmallIcon(R.drawable.icon) .setWhen(System.currentTimeMillis()).setAutoCancel(true) .setContentTitle(context.getString(R.string.flowzr_sync)) .setContentText(context.getString(R.string.flowzr_sync_require_tap)); nm.notify(SYNC_NOTIFICATION_ID, mNotifyBuilder.build()); Log.e(TAG, "Sync unactive: the required activity is missing."); return;// www.ja v a2s . c om } else { if (FlowzrSyncActivity.isRunning) { Log.i(TAG, "Sync already in progress"); } else { if ((System.currentTimeMillis() - FlowzrSyncOptions.last_sync_ts) > 30 * 1000) { Log.i(TAG, "Starting Auto-Sync Task"); fa.runOnUiThread(new Runnable() { public void run() { fa.setRunning(); } }); fa.initProgressDialog(); new FlowzrSyncEngine(fa); } else { Log.i(TAG, "Sync have just been done"); } } } }
From source file:jmri.enginedriver.threaded_application.java
void removeNotification() {
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(ED_NOTIFICATION_ID);
}
From source file:dentex.youtube.downloader.DashboardActivity.java
public void ffmpegJob(final File fileToConvert, final String bitrateType, final String bitrateValue) { BugSenseHandler.leaveBreadcrumb("ffmpegJob"); isFfmpegRunning = true;/* ww w .j a v a 2 s. c o m*/ vfilename = currentItem.getFilename(); // audio job notification init aBuilder = new NotificationCompat.Builder(this); aNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); aBuilder.setSmallIcon(R.drawable.ic_stat_ytd); aBuilder.setContentTitle(vfilename); String aExt = currentItem.getAudioExt(); basename = currentItem.getBasename(); final String audioFileName; // "compose" the audio file if (bitrateValue != null) { extrTypeIsMp3Conv = true; audioFileName = basename + "_" + bitrateType + "-" + bitrateValue + ".mp3"; } else { extrTypeIsMp3Conv = false; audioFileName = basename + aExt; } audioFile = new File(fileToConvert.getParent(), audioFileName); if (!audioFile.exists()) { new Thread(new Runnable() { @Override public void run() { Looper.prepare(); FfmpegController ffmpeg = null; try { ffmpeg = new FfmpegController(DashboardActivity.this); // Toast + Notification + Log ::: Audio job in progress... String text = null; if (!extrTypeIsMp3Conv) { text = getString(R.string.audio_extr_progress); type = YTD.JSON_DATA_TYPE_A_E; } else { text = getString(R.string.audio_conv_progress); type = YTD.JSON_DATA_TYPE_A_M; } Toast.makeText(DashboardActivity.this, "YTD: " + text, Toast.LENGTH_LONG).show(); aBuilder.setContentTitle(audioFileName); aBuilder.setContentText(text); aBuilder.setOngoing(true); aNotificationManager.notify(2, aBuilder.build()); Utils.logger("i", vfilename + " " + text, DEBUG_TAG); } catch (IOException ioe) { Log.e(DEBUG_TAG, "Error loading ffmpeg. " + ioe.getMessage()); } ShellDummy shell = new ShellDummy(); try { ffmpeg.extractAudio(fileToConvert, audioFile, bitrateType, bitrateValue, shell); } catch (IOException e) { Log.e(DEBUG_TAG, "IOException running ffmpeg" + e.getMessage()); } catch (InterruptedException e) { Log.e(DEBUG_TAG, "InterruptedException running ffmpeg" + e.getMessage()); } Looper.loop(); } }).start(); } else { PopUps.showPopUp(getString(R.string.long_press_warning_title), getString(R.string.audio_extr_warning_msg), "info", DashboardActivity.this); isFfmpegRunning = false; } }
From source file:dev.ukanth.ufirewall.Api.java
public static void showNotification(boolean status, Context context) { final int NOTIF_ID = 33341; String notificationText = ""; NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); Intent appIntent = new Intent(context, MainActivity.class); PendingIntent in = PendingIntent.getActivity(context, 0, appIntent, 0); int icon = R.drawable.widget_on; if (status) { notificationText = context.getString(R.string.active); icon = R.drawable.widget_on;/*from ww w . ja v a 2 s . c o m*/ } else { notificationText = context.getString(R.string.inactive); icon = R.drawable.widget_off; } builder.setSmallIcon(icon).setOngoing(true).setAutoCancel(false) .setContentTitle(context.getString(R.string.app_name)) .setTicker(context.getString(R.string.app_name)).setContentText(notificationText); builder.setContentIntent(in); mNotificationManager.notify(NOTIF_ID, builder.build()); }
From source file:com.piusvelte.sonet.core.SonetNotifications.java
@Override protected void onResume() { super.onResume(); // cancel any notifications ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(Sonet.NOTIFY_ID); loadNotifications();// w w w . j av a 2s .c o m }
From source file:com.shafiq.myfeedle.core.MyfeedleNotifications.java
@Override protected void onResume() { super.onResume(); // cancel any notifications ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(Myfeedle.NOTIFY_ID); loadNotifications();// ww w. j av a 2s . c om }
From source file:edu.mit.viral.shen.DroidFish.java
/** Set/clear the "heavy CPU usage" notification. */ private final void setNotification(boolean show) { if (notificationActive == show) return;//w w w.ja va2 s. c o m notificationActive = show; final int cpuUsage = 1; String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); if (show) { int icon = R.drawable.icon; CharSequence tickerText = getString(R.string.heavy_cpu_usage); long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_ONGOING_EVENT; Context context = getApplicationContext(); CharSequence contentTitle = getString(R.string.background_processing); CharSequence contentText = getString(R.string.lot_cpu_power); Intent notificationIntent = new Intent(this, CPUWarning.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify(cpuUsage, notification); } else { mNotificationManager.cancel(cpuUsage); } }
From source file:android.app.Activity.java
/** * @hide/* ww w .j a va 2 s. c om*/ */ private void showMigrateNotification() { boolean flag = false; if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } try { /* judge whether this App can migrate */ flag = mMigrator.checkMigratableApp(); } catch (RemoteException e) { Log.d(TAG, "Migrate failed in Dialog"); } if (flag) { Intent intent = new Intent(); intent.setClassName("com.android.migrationmanager", "com.android.migrationmanager.DeviceListDialog"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); /* on tapping, show dialog Activity */ Notification notification = new Notification.Builder(this) .setContentTitle("Migrator in " + getAppName()) .setContentText("start Migration: " + getLocalClassName()) .setSmallIcon(com.android.internal.R.drawable.ic_menu_send).setAutoCancel(true) .setContentIntent(pi).build(); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(Process.myUid(), notification); } }