Notifica in Android che ha lo stesso intento di fare clic. Sto inviando notifiche dopo aver installato il tema. Considera che installo 4 temi e 4 notifiche compaiono nella finestra di notifica, ma quando faccio clic su ciascuna notifica verrà avviata l'attività perticulari ma l'intento è avere gli stessi dati per ogni intenzione.Notifica multipla Android che invia gli stessi dati facendo clic su
mio codice va in questo modo
@SuppressWarnings("deprecation")
void sendInstalledNotification(String fileName, String packageName) {
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
String name = "";
try {
name += fileName.substring(fileName.lastIndexOf(".") + 1);
} catch (Exception e) {
Log.e("NewThemeChooser", "Invalid Package name");
e.printStackTrace();
}
name += " Installed";
Notification notification = new Notification(R.drawable.ic_launcher_9, name , System.currentTimeMillis());
Intent intent = new Intent(mContext , ThemeInfo.class);
Bundle bundle = new Bundle();
bundle.putString("apkid", packageName);
bundle.putBoolean("isApplied", false);
intent.putExtra("bundle", bundle);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
notification.setLatestEventInfo(mContext, name, "Click to Apply Theme", pendingIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
Log.d("NewThemeChooser__:ThemeChangeReceiver" , "hascode : " + packageName.hashCode() + " installed " + packageName);
notificationManager.notify(packageName.hashCode(), notification);
}
e sto stampando i dati intenti onCreate di ThemeInfo attività
Bundle bundle = getIntent().getBundleExtra("bundle");
apkid = bundle.getString("apkid");
isApplied = bundle.getBoolean("isApplied", false);
System.out.println("NewThemeChooser__:bundle apkid " + apkid);
Il risultato che sto ottenendo in ceppi è
D/NewThemeChooser__:ThemeChangeReceiver(4423): hascode : -186637114 installed com.test.theme.MiCrease
D/NewThemeChooser__:ThemeChangeReceiver(4423): hascode : 2106806482 installed com.test.theme.iPhone
D/NewThemeChooser__:ThemeChangeReceiver(4423): hascode : -1413669305 installed com.test.theme.Simpsons
D/NewThemeChooser__:ThemeChangeReceiver(4423): hascode : -2146296452 installed com.test.theme.AnnaTheme
I/System.out(4423): NewThemeChooser__:bundle apkid com.test.theme.MiCrease
I/System.out(4423): NewThemeChooser__:bundle apkid com.test.theme.MiCrease
I/System.out(4423): NewThemeChooser__:bundle apkid com.test.theme.MiCrease
I/System.out(4423): NewThemeChooser__:bundle apkid com.test.theme.MiCrease
In realtà avevo già avuto questa correzione in precedenza ma non si aggiornava. grazie @Oleg –
Wow. bella cattura. + 1 upvote. grazie per la condivisione –