简体   繁体   中英

Android Java Notification To Alarm

How do I rebuilt my Notification to get a 'Notification Alarm' I tried varois things but nothing worked, I am really frustated so I finally ask here.

Main Activity:

public void sendNotificationIfTimeEnd01() {
    Context context = getApplicationContext();
    Intent intent01 = new Intent(context, MainActivity.class);
    PendingIntent pendingIntent01 = PendingIntent.getActivity(this, 1, intent01, 0);
    NotificationCompat.Builder builder01 = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_notification)
            .setContentIntent(pendingIntent01)
            .setAutoCancel(true)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
            .setContentTitle(gamesJuliToStringArray[1])
            .setContentText("Spiel ist bereit")
            .setSubText("click");
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID_01, builder01.build());
    try {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
        r.play();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Condition in my Fragment:

    if (!notification062 && !buttonColor02.equals("red02")) {
        activity.sendNotificationIfTimeEnd01();
    }

Again I get Notifications if the conditions happens, but only inside of my application. Need help for rebuilding this into and alarm notification

在这里,您可以看到一个给定延迟的警报管理器示例,该警报管理器用于安排以后的通知时间。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM