0

Androidで独自の通知を行う方法を知っていることはすべて試しましたが、これは別のアプリで機能していますが、ハンドラーでは機能していません。私は基本的にこれを持っています:

NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification n = new Notification();

// Create the notification
Notification notification = new Notification(R.drawable.ic_launcher, "No GPS!", System.currentTimeMillis());
Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setAction("actionstring" + System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), msg.arg1, intent,0);

notification.setLatestEventInfo(getApplicationContext(),
Integer.toString(msg.arg1), mString, pendingIntent);

notification.flags = Notification.FLAG_AUTO_CANCEL;
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(0, notification);

// Give it an ID
nManager.notify(msg.arg1, n);

ただし、一意の通知は生成されず、オーバーライドされ続けます。一意性を制御するために msg.arg1 を使用しようとしましたが、これはうまくいかないようです。

4

0 に答える 0