Hello,
I have a problem with service/notification
My needs/requirements are: I want to have a program running permanently.
Therefore I take a look at the well known example FakePlayer
https://github.com/commonsguy/cw-and...ons/FakePlayer
because this fits to my needs.
My own program attempts according to the example, but also the original-code has the following behavior, which I do not understand:
If the program is started and then the service is started, the desired entry appears in the notificationbar.
If the program is in the background you can put it to front with the notificationbar, this works several times.
You can also use the home screen icon to put it to front with the homescreen-icon with which it was launched, this works several times.
So far, So good...
But in the following sequence:
-start program and start service
-lay program in the background
-put the program to front with the Notifikationbar
-lay program in the background
-put the program to front with the home screen icon
there is the following problem:
The programm is not put to the front, but a new instance is started (onCreate is called). These two instances can be separately killed with 2x back-button.
This behavior generally occurs when mixing the two possibilities of putting the program to front!
Can anyone reproduce this behavior?
What have I misunderstood / what have I done wrong?
My guess is that there is something wrong with the flag in the notification or intent.
However, I have seen at several places on the Internet precisely this use of the flags.
ORIGINAL-KODE "FakePlayer"
Notification note=new Notification(R.drawable.stat_notify_chat, "Can you hear the music?", System.currentTimeMillis());
Intent i=new Intent(this, FakePlayer.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.F LAG_ACTIVITY_SINGLE_TOP);
PendingIntent pi=PendingIntent.getActivity(this, 0, i, 0);
note.setLatestEventInfo(this, "Fake Player", "Now Playing: \"Ummmm, Nothing\"", pi);
note.flags|=Notification.FLAG_NO_CLEAR;
startForeground(1337, note);
Best regards
cstarling


