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);
你的服务