android-notifications

Oreo - Starting a service in the foreground

旧时模样 提交于 2019-11-28 00:24:55
问题 I have created a service that tracks the device's location as it moves. The service is started in by an Activity that binds to it, and in this activity there is a "Start Tracking" button. When this button is pressed, I need the service to start in the foreground, so that it stores the Locations that the device has moved to, even if the Activity that binds to it is closed, or the app is minimised. I understand that for the Service to be in the foreground, a notification must be displayed. I

Android Notification.Builder: show a notification without icon

耗尽温柔 提交于 2019-11-27 23:35:23
问题 String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.ic_notification_icon; android.app.Notification.Builder nbuilder = new Notification.Builder(this); nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName)); nbuilder.setContentText(msg); nbuilder.setOnlyAlertOnce(true); nbuilder.setOngoing(true); nbuilder.setSmallIcon(icon,level.level); How can I hide or completely delete

Set Drawable or Bitmap as icon In Notification in Android

陌路散爱 提交于 2019-11-27 22:51:20
I download a image from server as bitmap and convert it to drawable now i want to use this drawable as notification icon. But i am unable to do that. here is my code: Notification notification = new NotificationCompat.Builder(context) .setContentTitle(title) .setContentText(message) .setContentIntent(intent) .setSmallIcon(bitmap) .setWhen(when) .build(); but icon is a Resources int value so when i used it it gives error. Any help Edit: Now i update my code and now i am doing like that : Notification notification = new NotificationCompat.Builder(context) .setContentTitle(title) .setContentText

Building an Android notification server

≡放荡痞女 提交于 2019-11-27 22:42:03
问题 Is there any documentation on how to build a custom notification server for Android? I am currently using GCM but due to the nature of the app and the fact that notifications are a very important feature in my app, I would rather implement this service internally so that I can control the throughput and not have any artificial limitations (even if it's hundreds of thousands of notifications per day). I also would like to use the same notification server later on with the iOS version of the

Android: Presenting a notification during a call?

☆樱花仙子☆ 提交于 2019-11-27 22:34:58
I have a broadcast receiver that listens to incoming calls. And I want to tweak the incoming call screen. Right now I can present toasts and add notifications to the notification bar (BTW the user can't pull it down because the screen is locked, before accepting the call, which kinda sucks). I tried to show an alert but it crashed - is it not allowed? Is there a way for the code in the broadcast receiver to do other things, like change the avatar of the caller or give it a name (even if it doesn't exist in the contacts). Let's just say my broadcast receiver intercepts a call - can it add the

How to set the app icon as the notification icon in the notification drawer

泪湿孤枕 提交于 2019-11-27 19:46:28
As shown in the figure... I am getting my notification icon(on left to the red colour). But I need to display the app icon as shown by the black arrow public void notify(View view){ notification.setSmallIcon(R.drawable.ic_stat_name); notification.setTicker("Welcome to ****"); notification.setWhen(System.currentTimeMillis()); notification.setContentTitle("abcd"); notification.setContentText("abcd"); Intent intent = new Intent(this, home.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setContentIntent(pendingIntent

Android Color Notification Icon

浪尽此生 提交于 2019-11-27 19:40:50
I'm working on an app where I create a notification for the user. I want the icon to appear as white when it's in the status bar, but colored blue when it's being displayed in the drop down notification menu. Here's an example of the same thing being done by the Google Store app. White notification in status bar: Colored notification in drop down menu: How can I replicate this? What properties do I have to set? Edit: Here's my current code - I made the image all white with a transparent background, so it looks fine in the status bar, but in the notification drop, the image is still the same

How to get android notifications when app was closed?

£可爱£侵袭症+ 提交于 2019-11-27 18:52:58
From webserivce I am getting data in the form of dates and time, means for some particular date i am having some set of slots. The following diagram gives the detailed explanation. Here on each date I have some set to timings. Here what i want is to display notification at the particular date and time. If the response from database consists of tomorrow date like 07/12/2012 at 11:00 AM. I need to display notification at that time. I have some idea regarding notification manager and code i am using is.. Main.java NotificationManager notificationManager = (NotificationManager)getSystemService

Honeycomb notifications - How to set largeIcon to the right size?

╄→гoц情女王★ 提交于 2019-11-27 18:19:25
I find myself curious why the setLargeIcon method on Notification.Builder only accepts a Bitmap, with no overload to provide a resource id. Perhaps it was done for performance reasons, but it seems odd as setSmallIcon does accept a res drawable id. Notification.Builder builder = new Notification.Builder(application); // .... builder.setLargeIcon(iconBitmap); // Requires a Bitmap builder.setSmallIcon(iconResId); // Requires a drawable resource ID Notification notification = builder.getNotification(); Sadly the bitmap provided is not scaled in the notification, so the Bitmap needs to be provided

Changing LED color for notifications

我怕爱的太早我们不能终老 提交于 2019-11-27 17:52:08
I am basically just experimenting with Android development, and a couple of days ago I came across this app called " Go SMS Pro ", which, among other things, can set up notifications in different colors (blue, green, orange, pink and light blue). So, I have tried to do this myself in my own app, however I cannot change neiher the color nor the blinking internal of the LED. I currently use this code: public class MainActivity extends Activity { static final int NOTIFICATION_ID = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R