我正在尝试通过我的IntentService显示通知。
但没有显示: - (((
public class CreditcheckService extends IntentService {
AlertDialog dialog;
public CreditcheckService() {
super("CreditcheckService");
}
@Override
protected void onHandleIntent(Intent intent) {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setContentTitle("My notification")
.setContentText("Hello World!");
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(999, mBuilder.build());
}
答案 0 :(得分:2)
行
我添加了以下内容:
mBuilder.setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0));
它有效......