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:com.google.appinventor.components.runtime.ProbeBase.java
protected ProbeBase(ComponentContainer container) { super(container.$form()); // TODO Auto-generated constructor stub // Set up listeners form.registerForOnDestroy(this); mainUIThreadActivity = container.$context(); // start FunfManger Intent i = new Intent(mainUIThreadActivity, FunfManager.class); mainUIThreadActivity.startService(i); // bind to FunfManger (in case the user wants to set up the // schedule)//from w w w . j av a 2 s .co m doBindService(); // assign an unique notification id for each probe to use PROBE_NOTIFICATION_ID = getNotificationID(); // get Notification Manager String ns = Context.NOTIFICATION_SERVICE; mNM = (NotificationManager) mainUIThreadActivity.getSystemService(ns); Log.i(TAG, "created notification manager"); exportPath = new File(Environment.getExternalStorageDirectory(), form.getPackageName()) + File.separator + "export"; exportFormat = NameValueDatabaseService.EXPORT_CSV; // set the exporting format as csv by default }
From source file:br.com.imovelhunter.imovelhunterwebmobile.GcmIntentService.java
private void sendNotificationImovel(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent in = new Intent(this, NotificationActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, in, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.icone) .setContentTitle("Imovel Hunter").setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) .setContentText(msg);/* w w w.j a v a 2 s . co m*/ mBuilder.setAutoCancel(true); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); this.vibrar(); }
From source file:com.magnet.mmx.client.MMXWakeupIntentService.java
private void invokeNotificationForPush(GCMPayload payload) { // Launch the activity with action=MAIN, category=DEFAULT. Make sure that // it has DEFAULT category declared in AndroidManifest.xml intent-filter. PendingIntent intent = PendingIntent.getActivity(this.getApplicationContext(), 0, new Intent(Intent.ACTION_MAIN).setPackage(this.getPackageName()) .addCategory(Intent.CATEGORY_DEFAULT) // it is redundant .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED), PendingIntent.FLAG_UPDATE_CURRENT); // If title is not specified, use the app name (compatible with iOS push notification) String title = (payload.getTitle() == null) ? this.getApplicationInfo().name : payload.getTitle(); Notification.Builder noteBuilder = new Notification.Builder(this).setContentIntent(intent) .setAutoCancel(true).setWhen(System.currentTimeMillis()).setContentTitle(title) .setContentText(payload.getBody()); if (payload.getSound() != null) { // TODO: cannot handle custom sound yet; use notification ring tone. noteBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); }/*from www . j a v a2 s .c o m*/ if (payload.getIcon() != null) { noteBuilder.setSmallIcon( this.getResources().getIdentifier(payload.getIcon(), "drawable", this.getPackageName())); } else { noteBuilder.setSmallIcon(this.getApplicationInfo().icon); } if (payload.getBadge() != null) { noteBuilder.setNumber(payload.getBadge()); } NotificationManager noteMgr = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); noteMgr.notify(sNoteId++, noteBuilder.build()); }
From source file:ota.otaupdates.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPreferences.getBoolean("force_english", false)) { Locale myLocale = new Locale("en"); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale;/*www .j a v a 2 s .co m*/ res.updateConfiguration(conf, dm); } if (sharedPreferences.getBoolean("apptheme_light", false)) setTheme(R.style.AppTheme_Light); else setTheme(R.style.AppTheme_Dark); setContentView(R.layout.activity_main); build_url .append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP) : getString(R.string.download_url)) .append("/api/").append(Build.DEVICE).append("/").append(Build.TIME / 1000); build_dl_url.append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP) : getString(R.string.download_url)).append("/builds/"); delta_url.append((Utils.doesPropExist(Constants.URL_PROP) ? Utils.getProp(Constants.URL_PROP) : getString(R.string.download_url))).append("/delta/").append(Build.VERSION.INCREMENTAL); delta_dl_url.append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP) : getString(R.string.download_url)).append("/deltas/"); otaList = new ArrayList<>(); get_builds(); pb = (ProgressBar) findViewById(R.id.pb); pb.setVisibility(View.VISIBLE); final ListView ota_list = (ListView) findViewById(R.id.ota_list); adapter = new OTAUpdatesAdapter(getApplicationContext(), R.layout.row, otaList); ota_list.setAdapter(adapter); final CoordinatorLayout coordinator_root = (CoordinatorLayout) findViewById(R.id.coordinator_root); ota_list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, final int position, long id) { final String url = build_dl_url.toString() + otaList.get(position).getOta_filename(); if (Build.VERSION.SDK_INT >= 23 && !checkPermission()) allow_write_sd(); else if (sharedPreferences.getBoolean("disable_mobile", true) && isMobileDataEnabled()) { sb_network = Snackbar.make(coordinator_root, getString(R.string.disable_mobile_message), Snackbar.LENGTH_SHORT); sb_network.getView() .setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorSecond)); sb_network.show(); } else { new Thread(new Runnable() { @Override public void run() { create_notification(1, getString(R.string.app_name), getString( R.string.downloader_notification, otaList.get(position).getOta_filename())); Utils.DownloadFromUrl(url, otaList.get(position).getOta_filename()); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(1); runOnUiThread(new Runnable() { @Override public void run() { if (MD5.checkMD5(otaList.get(position).getOta_md5(), new File(DL_PATH + otaList.get(position).getOta_filename())) || !sharedPreferences.getBoolean("md5_checking", true)) trigger_autoinstall(DL_PATH + otaList.get(position).getOta_filename()); else { new AlertDialog.Builder(MainActivity.this) .setTitle(getString(R.string.md5_title)) .setMessage(getString(R.string.md5_message)).setNeutralButton( R.string.button_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .show(); } } }); } }).start(); } } }); }
From source file:jahirfiquitiva.iconshowcase.services.NotificationsService.java
public static void clearNotification(Context context, int ID) { NotificationManager notifManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notifManager.cancel(ID);/*w ww . j a va2s . com*/ }
From source file:ca.zadrox.dota2esportticker.service.ReminderAlarmService.java
private void notifyDebug() { final Resources res = getResources(); String contentTitle = "Debug Notification"; String contentText;//from w w w. jav a2s . c o m long currentTime = TimeUtils.getUTCTime(); long matchStart = TimeUtils.getUTCTime() + 60000; int minutesLeft = (int) (matchStart - currentTime + 59000) / 60000; if (minutesLeft < 2 && minutesLeft >= 0) { minutesLeft = 1; } if (minutesLeft < 0) { contentText = "debugNotification"; } else { contentText = "debugNotification"; } NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this).setContentTitle(contentTitle) .setContentText(contentText).setColor(res.getColor(R.color.theme_primary)) .setTicker(contentTitle + " is about to start.") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setLights(NOTIFICATION_ARGB_COLOR, NOTIFICATION_LED_ON_MS, NOTIFICATION_LED_OFF_MS) .setSmallIcon(R.drawable.ic_notification).setPriority(Notification.PRIORITY_DEFAULT) .setAutoCancel(true); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, notifBuilder.build()); }
From source file:com.pinplanet.pintact.GcmIntentService.java
private void sendChatNotification(String customData) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); JSONObject jsonObject = null;//from www. ja v a2 s . c o m JSONObject chatObject = null; GroupDTO groupDTO = new GroupDTO(); String chatMessage = "New Chat Message"; String groupId = ""; try { jsonObject = new JSONObject(customData); Log.d(TAG, "groupId: " + jsonObject.getString("groupId")); groupId = jsonObject.getString("groupId"); groupDTO.setId(jsonObject.getString("groupId")); SingletonLoginData.getInstance().setCurGroup(groupDTO); Log.d(TAG, "message: " + jsonObject.getString("message")); chatObject = jsonObject.getJSONObject("message"); chatMessage = chatObject.getString("content"); } catch (JSONException e) { Log.d(TAG, "sendChatNotification error: " + e.toString()); e.printStackTrace(); } //Intent it = new Intent(this, PushNotificationActivity.class); Intent it = new Intent(this, GroupContactsActivity.class); it.putExtra("groupId", groupId); it.putExtra("OpenThreads", true); //it.putExtra(LeftDeckActivity.SELECTED_OPTIONS, LeftDeckActivity.OPTION_NOTIFY); // add the following line would show Pintact to the preview page. // it.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, it, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("New Message") .setStyle(new NotificationCompat.BigTextStyle().bigText(chatMessage)) .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }).setAutoCancel(true) .setContentText(chatMessage); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); SingletonLoginData.getInstance().mNotificationManager = mNotificationManager; }
From source file:com.mutu.gpstracker.streaming.CustomUpload.java
private void clearNotification(Context context) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); mNotificationManager.cancel(NOTIFICATION_ID); }
From source file:fr.enseirb.odroidx.videomanager.Uploader.java
private final void createNotification() { mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new Notification.Builder(this); mBuilder.setContentTitle("Uploading Movie").setContentText("Upload in progress") .setSmallIcon(R.drawable.ic_launcher); }
From source file:org.transdroid.service.UpdateService.java
private void newNotification(String ticker, String title, String text, String downloadUrl, int notifyID) { // Use the alarm service settings for the notification sound/vibrate/colour SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); AlarmSettings settings = Preferences.readAlarmSettings(prefs); // Set up an intent that will initiate a download of the new version Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(downloadUrl)); // Create a new notification Notification newNotification = new Notification(R.drawable.icon_notification, ticker, System.currentTimeMillis()); newNotification.flags = Notification.FLAG_AUTO_CANCEL; newNotification.setLatestEventInfo(getApplicationContext(), title, text, PendingIntent.getActivity(getApplicationContext(), notifyID, i, 0)); // Get the system notification manager, if not done so previously if (notificationManager == null) { notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); }/* w w w . jav a 2 s. c om*/ // If sound enabled add to notification if (settings.getAlarmPlaySound() && settings.getAlarmSoundURI() != null) { newNotification.sound = Uri.parse(settings.getAlarmSoundURI()); } // If vibration enabled add to notification if (settings.getAlarmVibrate()) { newNotification.defaults = Notification.DEFAULT_VIBRATE; } // Add coloured light; defaults to 0xff7dbb21 newNotification.ledARGB = settings.getAlarmColour(); newNotification.ledOnMS = 600; newNotification.ledOffMS = 1000; newNotification.flags |= Notification.FLAG_SHOW_LIGHTS; // Send notification notificationManager.notify(notifyID, newNotification); }