Gelöschter Account
- Forum-Beiträge: 35
07.12.2012, 13:07:51 via Website
07.12.2012 13:07:51 via Website
Hallo Android Freunde.
In meiner App erstelle ich die Notification mit diesem Code:
Das Funktioniert einwandfrei, NUR: wenn ich die App am Smartphone mit Android 2.3.4 teste dann sehe ich das Icon der Notification und ein rotes Kreis mit der Anzahl der Benachrichtigungen (in diesem Fall 7) (Siehe Bild).
Wenn ich die gleiche App an dem Gerät mit Android 4.0.3 und höher ausführe, dann sehe ich nur das Icon und kein Kreis mit der Anzahl der Benachrichtigungen. Das Problem ist, der Kreis und die Anzahl dadrin sollte auf jedem Fall da sein.
Das Projekt wurde für Android 2.2 Platform entwickelt.
Kann mir jemand sagen woran es liegt dass der Kreis einmal bei Android 2.2 da ist und bei 4.0.3 und höher nicht mehr da ist ? Kann man es irgendwie machen dass der Kreis und die Anzeige bei allen Geräten kommt, oder ist es systemabhängig und somit nicht bei jedem Gerät möglich?
MfG.
In meiner App erstelle ich die Notification mit diesem Code:
1public class MainActivity extends Activity {
2
3 @Override
4 protected void onCreate(Bundle savedInstanceState) {
5 super.onCreate(savedInstanceState);
6 setContentView(R.layout.activity_main);
7
8 NotificationManager notificationManager = (NotificationManager)
9 this.getSystemService(this.NOTIFICATION_SERVICE);
10 Notification notification = new Notification(
11 R.drawable.ic_launcher,
12 "test" + 1, System.currentTimeMillis());
13 notification.flags |= Notification.FLAG_AUTO_CANCEL;
14
15 RemoteViews contentView = new RemoteViews(this.getPackageName(),R.layout.test_notif);
16 contentView.setTextViewText(R.id.tv_1, 12 + " "+16);
17 contentView.setTextViewText(R.id.tv_2,8 + " "+ 5);
18 contentView.setTextViewText(R.id.tv_3, "tja" +": "+ 89);
19 contentView.setTextViewText(R.id.tv_4, "hi "+" "+ 100);
20
21 contentView.setTextColor(R.id.tv_1, Color.BLACK);
22 contentView.setTextColor(R.id.tv_2, Color.BLACK);
23 contentView.setTextColor(R.id.tv_3, Color.BLACK);
24 contentView.setTextColor(R.id.tv_4, Color.BLACK);
25
26 notification.number = 7;
27 notification.contentView = contentView;
28 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
29 notification.contentIntent = pendingIntent;
30
31 notificationManager.notify(0, notification);
32 }
33}
2
3 @Override
4 protected void onCreate(Bundle savedInstanceState) {
5 super.onCreate(savedInstanceState);
6 setContentView(R.layout.activity_main);
7
8 NotificationManager notificationManager = (NotificationManager)
9 this.getSystemService(this.NOTIFICATION_SERVICE);
10 Notification notification = new Notification(
11 R.drawable.ic_launcher,
12 "test" + 1, System.currentTimeMillis());
13 notification.flags |= Notification.FLAG_AUTO_CANCEL;
14
15 RemoteViews contentView = new RemoteViews(this.getPackageName(),R.layout.test_notif);
16 contentView.setTextViewText(R.id.tv_1, 12 + " "+16);
17 contentView.setTextViewText(R.id.tv_2,8 + " "+ 5);
18 contentView.setTextViewText(R.id.tv_3, "tja" +": "+ 89);
19 contentView.setTextViewText(R.id.tv_4, "hi "+" "+ 100);
20
21 contentView.setTextColor(R.id.tv_1, Color.BLACK);
22 contentView.setTextColor(R.id.tv_2, Color.BLACK);
23 contentView.setTextColor(R.id.tv_3, Color.BLACK);
24 contentView.setTextColor(R.id.tv_4, Color.BLACK);
25
26 notification.number = 7;
27 notification.contentView = contentView;
28 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
29 notification.contentIntent = pendingIntent;
30
31 notificationManager.notify(0, notification);
32 }
33}
Das Funktioniert einwandfrei, NUR: wenn ich die App am Smartphone mit Android 2.3.4 teste dann sehe ich das Icon der Notification und ein rotes Kreis mit der Anzahl der Benachrichtigungen (in diesem Fall 7) (Siehe Bild).
Wenn ich die gleiche App an dem Gerät mit Android 4.0.3 und höher ausführe, dann sehe ich nur das Icon und kein Kreis mit der Anzahl der Benachrichtigungen. Das Problem ist, der Kreis und die Anzahl dadrin sollte auf jedem Fall da sein.
Das Projekt wurde für Android 2.2 Platform entwickelt.
Kann mir jemand sagen woran es liegt dass der Kreis einmal bei Android 2.2 da ist und bei 4.0.3 und höher nicht mehr da ist ? Kann man es irgendwie machen dass der Kreis und die Anzeige bei allen Geräten kommt, oder ist es systemabhängig und somit nicht bei jedem Gerät möglich?
MfG.
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.