Ich bin eine Anwendung für Android devoleping.Ich habe AlarmManager.Dieser AlarmManager kann nicht stoppable.Jedes Mal (alle 2 Sekunden) Überprüfung meiner Liste nach dem Zufallsprinzip.Random Nummer überprüfen Sie die Datenbank und die Entscheidung zu NotificationManager.İf Liste Zeile ist green.It nicht zu machen it.My Problem ist, wenn die Leitung green.My Benachrichtigungstext ist "t change.How doesn kann ich es behebenWie kann ich meinen Benachrichtigungstext ändern?
Mein AlarmManagerReceiver:
DatabaseHelper mDatabaseHelper;
ArrayList listData = new ArrayList<>();
ArrayList listDataoran = new ArrayList<>();
ArrayList listDataBoya = new ArrayList<>();
ArrayList listDataId = new ArrayList<>();
ArrayList listDatanumber = new ArrayList<>();
Random secilmiskisi ;
int secilmissayı;
@Override
public void onReceive(Context context, Intent intent) {
mDatabaseHelper = new DatabaseHelper(context);
Cursor data = mDatabaseHelper.getData();
while(data.moveToNext()){
listDataId.add(data.getString(0));
listData.add(data.getString(1));
listDatanumber.add(data.getString(2));
listDataoran.add(data.getString(3));
listDataBoya.add(data.getString(4));}
secilmiskisi = new Random();
secilmissayı = secilmiskisi.nextInt(listDataId.size()) + 0;
Toast.makeText(context, "Alarm !!!!!!!!!!", Toast.LENGTH_LONG).show();
cancelAlarm(context);
// setalarm(context);
if(!listDataBoya.contains("#1eac02")){
String table = "people_table";
ContentValues productDetailsContentValues = new ContentValues();
productDetailsContentValues.put("boya", "#1eac02");
String where = " id = " + listDataId.get(secilmissayı);
mDatabaseHelper.update(table, productDetailsContentValues, where , null);
Intent yesReceive = new Intent();
yesReceive.setAction(AppConstant.YES_ACTION);
PendingIntent pendingIntentYes = PendingIntent.getBroadcast(context, 12345, yesReceive, PendingIntent.FLAG_UPDATE_CURRENT);
Intent intenttt = new Intent(context,AnaMenu.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intenttt, 0);
Intent yesReceive2 = new Intent();
yesReceive2.setAction(AppConstant.STOP_ACTION);
PendingIntent pendingIntentYes2 = PendingIntent.getBroadcast(context, 12345, yesReceive2, PendingIntent.FLAG_UPDATE_CURRENT);
// Build notification
// Actions are just fake
Notification noti = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
noti = new Notification.Builder(context)
.setTicker(" size bir bildirim yolladı.")
.setContentTitle("")
.setContentText(listData.get(secilmissayı)+" i arama zamanı")
.setSmallIcon(R.drawable.familyiiii)
.addAction(R.drawable.cal, "Ara", pendingIntentYes)
.addAction(R.drawable.se, "Daha Sonra", pendingIntentYes2)
.setContentIntent(pIntent).getNotification();
}
// .setTicker(" size bir bildirim yolladı.").setSmallIcon(R.drawable.familyiiii)
// .setSubText("Bu mesaj ile artık" + isimler.get(random) + " arayacağın bir görevin oldu.")
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
setalarm(context);
}else if (listDataBoya.get(secilmissayı) != "#1eac02" ){
String table = "people_table";
ContentValues productDetailsContentValues = new ContentValues();
productDetailsContentValues.put("boya", "#1eac02");
String where = " id = " + listDataId.get(secilmissayı);
mDatabaseHelper.update(table, productDetailsContentValues, where , null);
Intent yesReceive = new Intent();
yesReceive.setAction(AppConstant.YES_ACTION);
PendingIntent pendingIntentYes = PendingIntent.getBroadcast(context, 12345, yesReceive, PendingIntent.FLAG_UPDATE_CURRENT);
Intent intenttt = new Intent(context, AnaMenu.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intenttt, 0);
Intent yesReceive2 = new Intent();
yesReceive2.setAction(AppConstant.STOP_ACTION);
PendingIntent pendingIntentYes2 = PendingIntent.getBroadcast(context, 12345, yesReceive2, PendingIntent.FLAG_UPDATE_CURRENT);
// Build notification
// Actions are just fake
Notification noti = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
noti = new Notification.Builder(context)
.setTicker(" size bir bildirim yolladı.")
.setContentTitle("")
.setContentText(listData.get(secilmissayı)+" i arama zamanı")
.setSmallIcon(R.drawable.familyiiii)
.addAction(R.drawable.cal, "Ara", pendingIntentYes)
.addAction(R.drawable.se, "Daha Sonra", pendingIntentYes2)
.setContentIntent(pIntent).getNotification();
}
// .setTicker(" size bir bildirim yolladı.").setSmallIcon(R.drawable.familyiiii)
// .setSubText("Bu mesaj ile artık" + isimler.get(random) + " arayacağın bir görevin oldu.")
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
setalarm(context);
}while (listDataBoya.get(secilmissayı) == "#1eac02"){////Here , is the problem.
String table = "people_table";
ContentValues productDetailsContentValues = new ContentValues();
productDetailsContentValues.put("boya", "#1eac02");
String where = " id = " + listDataId.get(secilmissayı);
mDatabaseHelper.update(table, productDetailsContentValues, where , null);
Intent yesReceive = new Intent();
yesReceive.setAction(AppConstant.YES_ACTION);
PendingIntent pendingIntentYes = PendingIntent.getBroadcast(context, 12345, yesReceive, PendingIntent.FLAG_UPDATE_CURRENT);
Intent intenttt = new Intent(context, AnaMenu.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intenttt, 0);
Intent yesReceive2 = new Intent();
yesReceive2.setAction(AppConstant.STOP_ACTION);
PendingIntent pendingIntentYes2 = PendingIntent.getBroadcast(context, 12345, yesReceive2, PendingIntent.FLAG_UPDATE_CURRENT);
// Build notification
// Actions are just fake
Notification noti = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
noti = new Notification.Builder(context)
.setTicker("AYNIKİŞİAYNIKİŞİAYNIKİŞİAYNIKİŞİAYNIKİŞİAYNIKİŞİ")
.setContentTitle("AYNIKİŞİAYNIKİŞİAYNIKİŞİAYNIKİŞİAYNIKİŞİ")
.setContentText(listData.get(secilmissayı)+" i arama zamanı")
.setSmallIcon(R.drawable.familyiiii)
.addAction(R.drawable.cal, "Ara", pendingIntentYes)
.addAction(R.drawable.se, "Daha Sonra", pendingIntentYes2)
.setContentIntent(pIntent).getNotification();
}
// .setTicker(" size bir bildirim yolladı.").setSmallIcon(R.drawable.familyiiii)
// .setSubText("Bu mesaj ile artık" + isimler.get(random) + " arayacağın bir görevin oldu.")
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
setalarm(context);
}
Dies ist das erste Mal, Aktivitäten erstellt:
Thi s ist das letzte Mal Aktivität:
Ich möchte meinen Benachrichtigungstext ändern, wenn die gewählte Nummer "s Zeile (Zufallszahl) grün ist.
Haben Sie die Dokumentation zum Ändern einer Benachrichtigung https://developer.android.com/training/notify-user/managing.html gelesen? – Adinia
Mögliches Duplikat von [Text der Benachrichtigung aktualisieren, nicht vollständige Benachrichtigung] (https://stackoverflow.com/questions/14885368/update-text-of-notification-not-entire-notification) – Adinia