2011-01-12 78 views
0

我得到的服務的問題:我想創建一個用戶,有沒有位置提供者說的通知,這是我的代碼:Android的服務通知

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); 

的應用給了我一個PendingIntent的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 

我怎樣才能解決這個問題?

感謝

回答

0

如何調用:

startForeground(id, notification); 
從服務