Nur notification ohne MainWindow?

  • Antworten:4
Alexander R.
  • Forum-Beiträge: 1.148

03.06.2011, 14:39:47 via Website

Hallo,
über folgenden Code erstelle ich eine Statusbar-Notification:
1String ns = Context.NOTIFICATION_SERVICE;
2NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
3
4int icon = R.drawable.notification_icon;
5CharSequence tickerText = "Hello";
6long when = System.currentTimeMillis();
7Notification notification = new Notification(icon, tickerText, when);
8
9Context context = getApplicationContext();
10CharSequence contentTitle = "My notification";
11CharSequence contentText = "Hello World!";
12Intent notificationIntent = new Intent(this, Test.class);
13PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
14notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
15
16notification.flags = Notification.FLAG_NO_CLEAR;
17
18private static final int HELLO_ID = 1;
19mNotificationManager.notify(HELLO_ID, notification);

Nun starte ich diese als Service in meiner Hauptanwenung:
1startService(new Intent(this, Statusbar.class);

Wie kann ich es nun realisieren, dass wenn ich die App starte, nur die Notification angezeigt wird (in der Statusbar) und nicht noch zusätzlich das MainWindow?

Gruß Alexander

Antworten
Aeefire
  • Forum-Beiträge: 172

03.06.2011, 14:54:18 via Website

1setContentView(R.layout.main);
wegmachen?

habs noch nicht probiert, aber logisch wärs ;)

Antworten
Ansgar M
  • Forum-Beiträge: 1.544

03.06.2011, 14:56:05 via App

Und zusätzlich das Theme im Manifest auf unsichtbar setzen.
Lg Ansgar

Antworten
Alexander R.
  • Forum-Beiträge: 1.148

03.06.2011, 15:04:39 via App

Ansgar M
Und zusätzlich das Theme im Manifest auf unsichtbar setzen.
Lg Ansgar

Wie auf unsichtbar?
Das Main soll ja angezeigt werden wenn ich auf die notification klicken also brauche ich ja die setContentView()

Gruß Alexander

Antworten
Aeefire
  • Forum-Beiträge: 172

03.06.2011, 15:19:57 via Website

aber meiner Meinung nach nicht in der OnCreate Methode. (also beim "ersten Starten" der app)... später, stehts dir ja frei..

Antworten