これで3時間遊んで、何が悪いのかわかりません。
private static Notification buildNotification(Context context) {
NotificationCompat.Builder b = new NotificationCompat.Builder(context);
b.setContentIntent(PendingIntent.getActivity(
context, 0, new Intent(context, MyActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT));
b.setTicker(context.getString(R.string.update_notification_title));
b.setContentTitle(context.getString(R.string.update_notification_title));
b.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.icon));
b.setSmallIcon(R.drawable.icon);
b.setOngoing(true);
b.setAutoCancel(false);
b.setProgress(100, 0, true);
Intent cancel = new Intent(context, Updater.class);
cancel.putExtra(EXTRA_CANCEL, true);
b.addAction(
R.drawable.discard_holo_dark,
context.getString(R.string.ui_cancel),
PendingIntent.getService(context, 0, cancel, PendingIntent.FLAG_UPDATE_CURRENT));
return b.build();
}
JellyBean でもデフォルトの NotificationBuilder を試しました。また、PendingIntent を getActivity に変更しようとしており、アイコンとテキストも置き換えようとしています。進行せず、autoCancel を使用して、setOngoing(false) を試行しました。ボタンによる運の変化はまだありません。4つの異なるデバイスで試しました。