Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //in onCreate()
- mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
- showNotification();
- private void showNotification() {
- Notification notification = new Notification(R.drawable.icon, "Scanner Service Started", System.currentTimeMillis());
- PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); //this is how we will launch an Activity when the user clicks the notification
- notification.setLatestEventInfo(this, getText(R.string.app_name), "Scanner Not Connected", contentIntent);
- notification.flags|=Notification.FLAG_ONGOING_EVENT;
- mNM.notify(NOTIFICATION_CONNECTION_CHANGED, notification); //send the notification to the system, to be displayed in the notification bar
- }
- private void updateNotification(String update) {
- Notification notification = new Notification(R.drawable.icon, update, System.currentTimeMillis());
- PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); //this is how we will launch an Activity when the user clicks the notification
- notification.setLatestEventInfo(this, getText(R.string.app_name), update, contentIntent);
- notification.flags|=Notification.FLAG_ONGOING_EVENT;
- mNM.notify(NOTIFICATION_CONNECTION_CHANGED, notification); //send the notification to the system, to be displayed in the notification bar
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement