我不斷收到上線這個錯誤,但如果我刪除空我得到的情況下錯誤告訴我初始化變量..空指針訪問:變量情況下只能是空在這個位置
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
這是我的代碼
public void createDialog(Enter_med enter_med) {
// TODO Auto-generated method stub
Context context = null;
NotificationManager nm;
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = "VIPUL";
CharSequence message = "Crazy About Android...";
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(), 0);
Notification notif = new Notification(R.drawable.ic_launcher,
"Crazy About Android...", System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
nm.notify(1, notif);
}
的錯誤意味着上下文是空 – Blackbelt
和'上下文語境= null;'有種解釋它 – keyser
你定義上下文爲空行兩上你得到錯誤。 – Zyber