cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ijas Ahamed N (JIRA)" <j...@apache.org>
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
                 URL: https://issues.apache.org/jira/browse/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

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

    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",
package_name))
            .setContentIntent(pendingIntent)
            .setOngoing(true)
            .build();

    startForeground(notificationId, notification);
} 

Here is the output i get https://i.stack.imgur.com/DbfGe.jpg

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
notification.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message