Android后台服务通知未向phonegap应用发送参数
我有一个内置于phonegap 5.0的应用程序,它还有一个触发通知的后台服务。一切正常,只是当我点击通知时,应用程序会像应该的那样打开,但我无法从通知中获取任何参数。在phonegap中,我使用它从本地通知中获取信息,但仅当通知是从应用程序中添加的,而不是从后台服务中添加时才起作用。Android后台服务通知未向phonegap应用发送参数,android,cordova,service,background,notifications,Android,Cordova,Service,Background,Notifications,我有一个内置于phonegap 5.0的应用程序,它还有一个触发通知的后台服务。一切正常,只是当我点击通知时,应用程序会像应该的那样打开,但我无法从通知中获取任何参数。在phonegap中,我使用它从本地通知中获取信息,但仅当通知是从应用程序中添加的,而不是从后台服务中添加时才起作用。 有什么我错过的吗?有人有过同样的问题吗 这是我的Android服务代码: public class MyService extends BackgroundService { private void show
有什么我错过的吗?有人有过同样的问题吗 这是我的Android服务代码:
public class MyService extends BackgroundService {
private void showNotification(int _nid, String _id, Date _now, String contentTitle, String contentText) {
_log=_log+_now.toString()+" activada notificacion"+contentTitle;
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setContentTitle(contentTitle)
.setContentText(contentText);
int NOTIFICATION_ID = _nid;
Uri alarmSound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification_sound);
builder.setSound(alarmSound);
builder.setSmallIcon(R.drawable.notification_icon);
if(_id.equals("0")){
}else{
File theImg = new File("https://s3-sa-east-1.amazonaws.com/iloveit/promo/" + _id + ".jpg");
if(!theImg.exists()) {
builder.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(getBitmapFromURL("https://s3-sa-east-1.amazonaws.com/iloveit/promo/" + _id + ".jpg")));
}
}
//builder.setLargeIcon(getBitmapFromURL("https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQhp07tKX-yadhAnHJXd5_oxHMtbYBhxvOeLqsEypSdFq5zThwiLg"));
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(
this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}}
你指的是什么参数?比如通知“id”。。。或title o text,但id对于知道应用程序中显示的页面很重要。.“参数”称为“附加”,您应该在
Intent
中传递它们。您可以发布示例代码吗!!我不知道如何传递额外信息。请阅读基本知识:你指的是什么参数?例如,通知“id”。。。或title o text,但id对于知道应用程序中显示的页面很重要。.“参数”称为“附加”,您应该在Intent
中传递它们。您可以发布示例代码吗!!我不知道如何通过考试,请阅读基本知识: