Notification Verhalten unter Android 2.2 und Android 4.0.3 und höher

  • 5 Antworten
  • Letztes Antwortdatum
Z

zblack

Gast
Hallo Android Freunde.
In meiner App erstelle ich die Notification mit diesem Code:
Code:
public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

			NotificationManager notificationManager = (NotificationManager) 
					this.getSystemService(this.NOTIFICATION_SERVICE);
			Notification notification = new Notification(
					R.drawable.ic_launcher,
					"test" + 1, System.currentTimeMillis());
			notification.flags |= Notification.FLAG_AUTO_CANCEL;
			
	        RemoteViews contentView = new RemoteViews(this.getPackageName(),R.layout.test_notif);
	        contentView.setTextViewText(R.id.tv_1, 12 + " "+16);
	        contentView.setTextViewText(R.id.tv_2,8 + " "+ 5);
	        contentView.setTextViewText(R.id.tv_3, "tja" +": "+ 89);
	        contentView.setTextViewText(R.id.tv_4, "hi "+" "+ 100);

	        contentView.setTextColor(R.id.tv_1, Color.BLACK);
	        contentView.setTextColor(R.id.tv_2, Color.BLACK);
	        contentView.setTextColor(R.id.tv_3, Color.BLACK);
	        contentView.setTextColor(R.id.tv_4, Color.BLACK);

			notification.number = 7;
			notification.contentView = contentView;
			PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
	        notification.contentIntent = pendingIntent;

			notificationManager.notify(0, notification);
	}
}
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?
 

Anhänge

  • screen_mit_der_anzahl_2_3_4.png
    screen_mit_der_anzahl_2_3_4.png
    23,5 KB · Aufrufe: 313
vielen Dank für diese zahlreiche Antworten. Hat mir sehr geholfen
 
lol bitte :D

der rote kreis mit der anzahl ist kein standard android feature. das existiert nicht im sdk

das ist ein feature der version auf deinem gerät.
 
maniac103 schrieb:


Ausgehend von diesem Link lässt sich die Frage des TO ja klären:

he number of events that this notification represents. For example, in a new mail notification, this could be the number of unread messages. The system may or may not use this field to modify the appearance of the notification. For example, before HONEYCOMB, this number was superimposed over the icon in the status bar. Starting with HONEYCOMB, the template used by Notification.Builder has displayed the number in the expanded notification view. If the number is 0 or negative, it is never shown.

Es ist einfach ab Android 3 nicht mehr vorgesehen, dass die Zahl in der Statusbar angezeigt wird...

EDIT: Oh man, sorry, ich sollte Antworten erstmal vollständig lesen... maniac hat ja schon drauf hingewiesen, dass dort die Antwort steht ^^
 
ok wusste gar nicht, dass es da überhaupt mal eine nummer gab.

aber ok, man lernt ja nie aus :D
 

Ähnliche Themen

AnnaBauer21
Antworten
0
Aufrufe
499
AnnaBauer21
AnnaBauer21
M
Antworten
21
Aufrufe
1.403
swa00
swa00
Mr-Fisch
Antworten
5
Aufrufe
1.001
migi01
migi01
Mr-Fisch
Antworten
8
Aufrufe
1.029
Mr-Fisch
Mr-Fisch
M
Antworten
9
Aufrufe
830
mkuz24
M
Zurück
Oben Unten