私は、デバイスを1週間に2回呼び出すプッシュ通知を作成して、特定のアクティビティに誘導したいと考えています。あなたはこれを実装するために関数やアルゴリズムをどのように使うべきか、どのような時に私を見せてもらえますか?ありがとうAndroid - 1週間に2回ポップアップするプッシュ通知を作成する
0
A
答えて
0
通知の通知時間を設定するコードは次のとおりです。アプリが終了したときに通知されます。ここで
public class AlarmTiming {
static AlarmManager alarmManager;
static PendingIntent pendingIntent;
static DatabaseAdapter databaseAdapter;
static String[] pieces;
/*..duration time for alarm to notify you every 3 days ...
mean twice in a week.. you just have to set it again when notification is reached/alarmed
for the next duration*/
static int alarmDuration = 72;
public static void SetTwiceNotification(Context c) {
String formattedDate = new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime());
pieces = formattedDate.split(":");
Calendar calNow = Calendar.getInstance();
Calendar calSet = (Calendar)calNow.clone();
calSet.set(Calendar.HOUR_OF_DAY, Integer.parseInt(pieces[0])+alarmDuration);
calSet.set(Calendar.MINUTE, Integer.parseInt(pieces[1]));
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);
if(calSet.compareTo(calNow) <= 0) {
calSet.add(Calendar.DATE, 1);
}
setAlarm(calSet,c);
}
private static void setAlarm(Calendar targetCal,Context c) {
Intent intent = new Intent(c, AlarmBroadcaster.class);
//..
pendingIntent = PendingIntent.getBroadcast(c, 1, intent,PendingIntent.FLAG_ONE_SHOT);
alarmManager = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);
}
は...
public class AlarmBroadcaster extends BroadcastReceiver {
Context context;
String typeFlag;
int flagId;
@Override
public void onReceive(Context context, Intent intent) {
this.context = context;
createNotification(context);
AlarmTiming.SetTwiceNotification(context);
}
public void createNotification(Context context) {
PendingIntent pendingIntent = PendingIntent.getActivity(context,0, new Intent(context,LoginActivity.class),0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.notifi_righter_logo);
//...
NotificationCompat.InboxStyle inboxStyle =
new NotificationCompat.InboxStyle();
String[] events = {"You are reminded to review your APP"};
// Sets a title for the Inbox in expanded layout
inboxStyle.setBigContentTitle(" Notification !");
// Moves events into the expanded layout
for (int i=0; i < events.length; i++) {
inboxStyle.addLine(events[i]);
}
// Moves the expanded layout object into the notification object.
builder.setStyle(inboxStyle);
builder.setContentIntent(pendingIntent);
builder.setDefaults(NotificationCompat.DEFAULT_SOUND);
builder.setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1,builder.build());
}
}
+0
私はあなたが任意のクエリを持っているかどうか教えて! –
+0
あなたはクエリを意味しますか? –
+0
意味...コードに関する質問がある場合...どのような機能が何をしているのか理解できない場合:) –
関連する問題
- 1. 通知ポップアップをAngular.jsで1回だけ表示するには?
- 2. UnityとFirebaseで1週間アクティブではないユーザーにプッシュ通知を送信
- 3. 2週間ごとにUILocalNotificationに通知する方法
- 4. 通知時にイオン2ページが2回プッシュされる
- 5. Android通知プッシュ
- 6. 1行にテキストを表示するAndroidプッシュ通知
- 7. CloudKitレコード作成プッシュ通知
- 8. 数週間後にFirebaseプッシュ通知が機能しない
- 9. イオン1プッシュ通知
- 10. Androidのプッシュ通知を解析する
- 11. Androidでプッシュ通知をトラッキングする
- 12. Android向けプッシュ通知ionic 2
- 13. Androidプッシュ通知、fcm
- 14. Androidプッシュ通知コンポーネント
- 15. Androidのプッシュ通知
- 16. Android:プッシュ通知C2DM
- 17. Android用リマインダー通知を作成する
- 18. Android - 通知を作成する
- 19. プッシュ通知をテストするためのプロビジョニングプロファイルを作成する
- 20. ポップアップによるイオン2の通知(OneSignal)
- 21. Android GCMはプッシュ通知を複数回送信します
- 22. C#、WPFでWindowsで「プッシュ通知」サービスを作成するには?
- 23. 週に2回、cronジョブを設定する方法(週2回)
- 24. イオン2ローカル通知とプッシュ通知
- 25. javafxを使用してAndroidでプッシュ通知を作成
- 26. GCMプッシュ通知に代わるAndroid
- 27. テキストを1週間に1回変更する
- 28. ポップアップでChrome拡張通知を作成する
- 29. 週3回のトリガー通知Swift 3
- 30. iOSプッシュ通知が2回表示されます
ユーザーアラームマネージャと週に異なる時間のための2つのアラームを設定し、通知を受信する放送受信機クラスです。 –
私にそれを行う方法を教えてください –
ok私はあなたのためのコードをアセンブルさせてください....私の答えに見てください –