自分のアプリケーションにAndroidのローカル通知を使用したいと思います。 アプリが24時間開いていない場合は、ローカル通知が送信されます。 どのようにすればいいか教えてください。Androidでのローカル通知の送信
答えて
参照:Local Notifications in Android? アラームマネージャを使用してインテントを1時間ごとにスケジュールすることができます。
クイックレスポンスありがとうございますが、アプリが閉鎖されている場合にアラームマネージャーを使用することができます。アプリが閉鎖されている場合、通知はどのようにトリガーされますか? –
はい、アラームマネージャは、アプリが閉じている場合でも使用できます。しかし、アプリケーションがインストールされているときにのみ、アラームマネージャーを設定することはできません。アプリケーションがロードされているとき(atleast once)(http://stackoverflow.com/a/8492846/986105を参照)。これを見て、アラームマネージャを使用して通知を作成してください:http://smartandroidians.blogspot.com/2010/04/alarmmanager-and-notification-in.html – KrispyDonuts
あなたはタイトルの単一の通知で複数行のテキスト、ティッカー、アイコン、サウンド..次のコードを使用して、ビッグデータ、すなわちでローカル通知を発射する場合..私はそれはあなたを助けると思います。..
Intent notificationIntent = new Intent(context,
ReminderListActivity.class);
notificationIntent.putExtra("clicked", "Notification Clicked");
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP); // To open only one activity
// Invoking the default notification service
NotificationManager mNotificationManager;
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
context);
Uri uri = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setContentTitle("Reminder");
mBuilder.setContentText("You have new Reminders.");
mBuilder.setTicker("New Reminder Alert!");
mBuilder.setSmallIcon(R.drawable.clock);
mBuilder.setSound(uri);
mBuilder.setAutoCancel(true);
// Add Big View Specific Configuration
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
String[] events = null;
events[0] = new String("Your first line text ");
events[1] = new String(" Your second line text");
// Sets a title for the Inbox style big view
inboxStyle.setBigContentTitle("You have Reminders:");
// Moves events into the big view
for (int i = 0; i < events.length; i++) {
inboxStyle.addLine(events[i]);
}
mBuilder.setStyle(inboxStyle);
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(context,
ReminderListActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder
.create(context);
stackBuilder.addParentStack(ReminderListActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder
.getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
// notificationID allows you to update the notification later on.
mNotificationManager.notify(999, mBuilder.build());
Intent intent = new Intent(context, yourActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder b = new NotificationCompat.Builder(context);
b.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
.setTicker("notification")
.setContentTitle("notification")
.setContentText("notification")
.setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_SOUND)
.setContentIntent(pIntent)
.setContentInfo("Info");
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, b.build());
- 1. ローカル通知の送信を停止するandroid
- 2. ローカルSNMPサーバに通知を送信
- 3. Xamarin.Forms Androidローカル通知が送信されない
- 4. Android搭載ハーブ通知 - サブセットへの通知の送信
- 5. Androidアプリケーションユーザーにプッシュ通知を送信
- 6. Firebase - 通知を送信する(Android)
- 7. Android Oが通知を送信する
- 8. Xamarin Androidでしばらくしてからローカル通知を送信
- 9. Androidでのローカル通知音の停止
- 10. Ionic 3の特定のページにローカル通知データを送信
- 11. エラーの場合にローカル通知を再送信
- 12. 通知-送信クーロン
- 13. リモート通知を受信したときにローカル通知が送信されないのはなぜですか?
- 14. Rabbitmqで通知を送信
- 15. Firebaseで通知を送信
- 16. 送信通知はandroidの以前の通知を上書きします
- 17. androidの着信メール通知
- 18. Androidのモバイルデバイスエンドポイント間でAWS SNS通知を送信する方法
- 19. 再送信docusignイベント通知
- 20. 通知を送信する
- 21. wso2is5.3:送信メール通知
- 22. WSO2送信回復通知
- 23. ブロードキャストプッシュ通知を送信
- 24. Laravel 5.3通知送信エラー
- 25. Azureに基づいたAndroidアプリへのターゲットプッシュ通知の送信
- 26. ラズベリーのAndroidの事 - Firebaseからプッシュ通知を送信
- 27. Androidでユニークなテキストで通知を送信する
- 28. Androidアプリで着信通知を受信
- 29. バックエンドシステムからAzureプッシュ通知ハブへのプッシュ通知の送信
- 30. WatchKitのローカル通知
なぜ私はあなたがサービスを作成して時刻を確認すべきだと思うが、通知を示すためにuはそれについて読んでなければなりませんuはアラーム – Zamani
を使用してはいけません。 =) – Gorets
Gorets、あなたは大丈夫です。アプリが閉じられたときに通知がトリガーされるので、何らかのサービスを使用する必要があります。 –