Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android服务通知_Android_Service_Notifications - Fatal编程技术网

Android服务通知

Android服务通知,android,service,notifications,Android,Service,Notifications,我遇到一个服务问题:我想创建一个通知,告诉用户没有位置提供程序,这是我的代码: Notification notificationNoProvider = new Notification(R.drawable.icon, message, System.currentTimeMillis()); Intent notificationIntent = new Intent(); PendingIntent pendingIntent = PendingIntent.getActivity(

我遇到一个服务问题:我想创建一个通知,告诉用户没有位置提供程序,这是我的代码:

Notification notificationNoProvider = new Notification(R.drawable.icon, message, System.currentTimeMillis());

Intent notificationIntent = new Intent();

PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0, notificationIntent, 0);

notificationNoProvider.setLatestEventInfo(this,message,message, pendingIntent);

notificationManager.notify(message.hashCode(), notificationNoProvider);
应用程序在PendingContent的getActivity方法中为我提供了一个NullPointerException。 我也尝试使用getApplicationContext而不是geBasecontext,但应用程序仍然会爆炸。 我发现问题出在getActivity的这一行:

public static PendingIntent  [Search] getActivity(Context context, int requestCode,Intent intent, int flags) {
    String packageName = context.getPackageName();//here the application explodes
我怎样才能解决这个问题

谢谢

打电话来怎么样:

startForeground(id, notification);
你的服务