cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ijas Ahamed N (JIRA)" <>
Subject [jira] [Created] (CB-12561) Incorrect service foreground notification generated
Date Fri, 10 Mar 2017 07:09:04 GMT
Ijas Ahamed N created CB-12561:

             Summary: Incorrect service foreground notification generated
                 Key: CB-12561
             Project: Apache Cordova
          Issue Type: Bug
          Components: Android
    Affects Versions: 3.5.0
         Environment: Android M(v23)
            Reporter: Ijas Ahamed N

I have a service in my android application and i dont want android to kill the service due
to memory shortage. So i am running my service with foreground notification.
Here is my code for foreground service

public int onStartCommand(Intent intent, int flags, int startId) {
    context = this.getApplicationContext();

    return START_NOT_STICKY;

private void notifyService() {
    String package_name = this.getApplication().getPackageName();

    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    Bitmap icon = BitmapFactory.decodeResource(getResources(),
            this.getApplication().getResources().getIdentifier("icon", "drawable-hdpi", package_name));

    Notification notification = new NotificationCompat.Builder(this)
            .setContentTitle("Smart Home")
            .setContentText("Smart Home running in background")
.setSmallIcon(this.getApplication().getResources().getIdentifier("icon", "drawable-hdpi",

    startForeground(notificationId, notification);

Here is the output i get

Notification is generated but notification title is not as i set. Also, when i click this
notification, it's moving to app info activity. But i want to move to my main activity.

Is there any problem with my code or cordova is replacing foreground notification with other

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message