Hi,
You are right, the Eclipse launch is really makeing some mess:
I have two condition:
1. Launch with eclipse: It does't start a new activity if I make
visible the application again with the notification, but start a
'second' activity if I try it with the launcher icon.
2. Normal launch: opposite of the previous one :).
I tried your PendingIntent solution, but it does't solved the
problem.
Right now my NotificationHelper looks like this:
public class NotifierHelper {
private Context context;
private NotificationManager notificationManager;
public NotifierHelper (Context context){
Log.v(TAG, "NotifierHelper create");
this.context = context;
notificationManager =
(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
}
public void showNotification(){
Log.v(MediaService.TAG, "showNofitication called");
Notification notification = new Notification();
notification.icon = R.drawable.notification_icon;
notification.flags = Notification.FLAG_ONGOING_EVENT |
Notification.FLAG_NO_CLEAR;
Intent baseIntent = new Intent(context,
ViewPagerActivity.class);
baseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
baseIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
baseIntent.setAction(Intent.ACTION_MAIN);
baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent pendingIntent =
PendingIntent.getActivity(context, 0,
baseIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, "Radio On", "You are
now
listening a radio...", pendingIntent);
notificationManager.notify(1, notification);
}
}
And I am initializing in the activity on this way:
....
public static NotifierHelper notifierHelper;
.....
@Override
public void onCreate( Bundle savedInstanceState ){
super.onCreate(savedInstanceState);
notifierHelper = new NotifierHelper(thist);
...
I guess the problem is somewhere on the this/context line, or i don't
konow....
Thanks for your help ,
Leslie
On febr. 1, 23:37, Kostya Vasilyev <[email protected]> wrote:
> Is the app originally launched from Eclipse?
>
> If so, beware that Eclipse uses a different intent than would normally
> be used by the Launcher(s), so you may get duplicates like this.
>
> To get a good test, either don't launch from Eclipse, or first press
> Back to close the initial activity, start a new one from Launcher, then
> test your notifications.
>
> Other than that, here is what I use for widgets / notifications.
>
> It matches the intent used by Launcher(s), and so resumes an existing
> activity if there is one:
>
> Intent baseIntent = new Intent(context, **** ACTIVITY CLASS
> HERE ****.class);
> baseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> baseIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
> baseIntent.setAction(Intent.ACTION_MAIN);
> baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
>
> PendingIntent pendingIntent =
> PendingIntent.getActivity(context, 0, baseIntent,
> PendingIntent.FLAG_UPDATE_CURRENT);
>
> -- Kostya
>
> On 02/02/2012 02:25 AM, leslie.karpati wrote:
>
>
>
>
>
>
>
> > Hi!
>
> > I'am writing an online radio streamer application. It's working very
> > well (activity->bind service->notificiation bar, ...etc), but
> > sometimes when I go back to the UI (ex.: click to the application icon
> > from the menu, when the service and the activity are already running -
> >> onResume) it's start a new/second/duplicated activity, but the old
> > one does't killed. For example: when I press key back after that it's
> > destroy the new activity and going to back to the old one, and I can
> > kill it too.
>
> > I put this code to the onResume:
> > Log.v(TAG, "Activity onResume called. Context:"+context);
> > and onlye when the problem is occured (stared the second activity
> > above the old one), I got a different contex id.
>
> > Where is the problem?
>
> > Thanks,
> > Leslie
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en