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:adapter.notification.MyFcmListenerService.java
private void sendNotification(RemoteMessage.Notification notification) { Intent intent = new Intent(this, MainActivity.class); 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.ic_stat_utn).setContentTitle(notification.getTitle()) .setContentText(notification.getBody()).setGroup(notification.getTag()).setAutoCancel(true) .setColor(ContextCompat.getColor(getApplicationContext(), R.color.caldroid_holo_blue_dark)) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of adapter.notification */, notificationBuilder.build()); }
From source file:ac.robinson.paperchains.SoundCloudUploadTask.java
public SoundCloudUploadTask(PaperChainsActivity context, ApiWrapper wrapper, Token accessToken, String pageId, Rect audioRect) {/*from w ww . ja v a 2 s . com*/ mContext = new WeakReference<>(context); // set up upload parameters mApiWrapper = wrapper; mAccessToken = accessToken; mClientId = context.getString(R.string.soundcloud_client_id); mUploadFileTitle = context.getString(R.string.audio_upload_file_title); mUploadFileDescription = context.getString(R.string.audio_upload_file_description); mPageId = pageId; mAudioRect = audioRect; // set up notifications mNotifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle(context.getString(R.string.audio_upload_title)) .setContentText(context.getString(R.string.audio_upload_progress)) .setSmallIcon(R.drawable.ic_notification).setColor(context.getResources().getColor(R.color.primary)) .setAutoCancel(true); }
From source file:com.moto.miletus.application.ble.neardevice.NearDeviceNotification.java
@Override public void onReceive(final Context context, final Intent intent) { Log.i(TAG, intent.toString());//from w w w . j av a2 s.c o m if (!intent.getAction().equals(Strings.NEAR_DEVICE)) { return; } this.context = context; this.systemService = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); findDevice(); }
From source file:bhtech.com.cabbydriver.services.MyGcmListenerService.java
private void sendNotification(String message) { Intent intent = new Intent(this, ChooseRouteToCustomerController.class); 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.ic_stat_ic_notification) .setContentTitle("GCM Message").setContentText(message).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:be.thomasave.executeorder42.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w. ja v a 2 s. co m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); 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.icon).setContentTitle("Execute Order 42").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:br.ufrn.dimap.pubshare.download.service.DownloaderService.java
/** * The IntentService calls this method from the default worker thread with * the intent that started the service. When this method returns, IntentService * stops the service, as appropriate./*from w w w . j av a2 s . c o m*/ */ @Override protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent on DownloadService"); Article selectedArticle = (Article) intent.getSerializableExtra(Article.KEY_INSTANCE); if (!AndroidUtils.isExternalStorageAvailable()) { // Generate Menssages NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_menu_notifications) .setContentTitle(getResources().getString(R.string.external_storage_unavailable)) .setContentText(getResources().getString(R.string.check_media_availability)); Notification notification = mBuilder.build(); // Set the Notification as ongoing notification.flags = notification.flags | Notification.FLAG_AUTO_CANCEL; NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nManager.notify(0, notification); return; } DownloadManager dowloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); // since API level 9 Request request = new Request(Uri.parse(selectedArticle.getRemoteLocation())); request.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); request.setTitle(selectedArticle.getTitle()); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, selectedArticle.generateFileName()); request.setVisibleInDownloadsUi(true); long enqueue = dowloadManager.enqueue(request); Log.d(TAG, "Download enqueue..." + enqueue); ArticleDownloaded articleDownloaded = new ArticleDownloaded(); articleDownloaded.setDownloadKey(enqueue); DownloadDao downloadDao = new DownloadDao(this); downloadDao.insert(articleDownloaded); Log.d(TAG, "Insert " + articleDownloaded + " in SqLite: OK"); }
From source file:ar.uba.fi.splitapp.MockServer.java
private static void showNotification(String header, String message, Bitmap icon) { Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(appContext) .setSmallIcon(R.drawable.logo).setLargeIcon(MockServer.getCircleBitmap(icon)) .setContentTitle(header).setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setColor(appContext.getResources().getColor(R.color.colorPrimaryLight)); NotificationManager notificationManager = (NotificationManager) appContext .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:cc.psdev.heywifi.MainService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i("onStartCommand", "called"); wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); dm = new DBManager(getApplicationContext(), "data", null, DATABASE_VERSION); audm = (AudioManager) getSystemService(Context.AUDIO_SERVICE); actm = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); pref = new SharedPrefSettings(this); Thread thread = new Thread(this); thread.start();/*from www . j a v a2 s . c om*/ return START_STICKY; }
From source file:com.kasoft.pushnot.GcmIntentService.java
private void sendNotification(String msg, String title, String form) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent appMainIntent = new Intent(getApplicationContext(), MainActivity.class); appMainIntent.putExtra("title", title); appMainIntent.putExtra("form", form); //appMainIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); appMainIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, appMainIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle().bigText(form)).setContentText(form); mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.bakhtiyor.android.tumblr.TumblrService.java
@Override public void onCreate() { super.onCreate(); APP_TITLE = getString(R.string.app_name); GENERATOR = APP_TITLE + "/Android"; notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); }