Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-18 Thread TreKing
On Wed, Jul 18, 2012 at 3:51 AM, Dirk Vranckaert
wrote:

> Thanks for the help anyway (and sorry for my mistake ;) ) and happy
> coding! :)


Ha. That's usually how it works out. Every time I post here it ends up
being something stupid and completely unrelated.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-18 Thread Dirk Vranckaert
I solved my own issue...

I was setting some flags on my intent:
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_HISTORY 
| Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK;

But when using the FLAG_ACTIVITY_NO_HISTORY, my activity that is launched 
is not kept in the activity-stack, meaning when I start from that 
'invisible' activity another activity 'for-result' I can never com back in 
the onActivityResult because it doesn't know where to go... So my activity 
gets killed and nothing happens.

If run my original code without the flag  FLAG_ACTIVITY_NO_HISTORY it works 
perfect...

Thanks for the help anyway (and sorry for my mistake ;) ) and happy coding! 
:)

Kr

Dirk

Op woensdag 18 juli 2012 09:25:14 UTC+2 schreef Dirk Vranckaert het 
volgende:
>
> And also.. If I do not use FLAG_UPDATE_CURRENT, then what flag(s) should I 
> define?
>
> Op woensdag 18 juli 2012 09:23:57 UTC+2 schreef Dirk Vranckaert het 
> volgende:
>>
>> It always worked find to just pass the extras (in fact it's not only the 
>> widget ID that i'm passing, there is some other stuff in there to..). It 
>> since the launced activity starts another activity for result it doesn't 
>> work anymore... So I guess using the extras or the data element won't make 
>> a difference. I even tried to launch the activity without passing anything 
>> and still my onActivityResult method is not reached...
>>
>> So what I currently do is nothing more than this (so without any extras):
>> Intent intent = new Intent(ctx, activity);
>> PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 
>> widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
>>
>> So then what do you mean with create different actions?
>>
>> Do you mean to create different pendingIntents (so with a different 
>> requestCode, something like "start" + widgetId and "stop" + widgetId) or do 
>> you mean to create two different activities (cause that is whay I already 
>> have, a start- and stop-activity)?
>>
>> Op woensdag 18 juli 2012 09:14:21 UTC+2 schreef TreKing het volgende:
>>>
>>> On Wed, Jul 18, 2012 at 2:13 AM, TreKing  wrote:
>>>
 This makes each PendingIntent unique and they wrote overwrite each other
>>>
>>>
>>> This makes each PendingIntent unique and they *won't* overwrite each 
>>> other.
>>>
>>>
>>> -
>>> TreKing  - Chicago 
>>> transit tracking app for Android-powered devices
>>>
>>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-18 Thread TreKing
On Wed, Jul 18, 2012 at 2:23 AM, Dirk Vranckaert
wrote:

> I even tried to launch the activity without passing anything and still my
> onActivityResult method is not reached...
>

You're not sending a negative request code, by chance, are you?


> Do you mean to create different pendingIntents (so with a different
> requestCode, something like "start" + widgetId and "stop" + widgetId) or do
> you mean to create two different activities (cause that is whay I already
> have, a start- and stop-activity)?


Two different PendingIntents.
http://developer.android.com/reference/android/content/Intent.html#setAction%28java.lang.String%29

And also.. If I do not use FLAG_UPDATE_CURRENT, then what flag(s) should I
> define?
>

None.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-18 Thread Dirk Vranckaert
And also.. If I do not use FLAG_UPDATE_CURRENT, then what flag(s) should I 
define?

Op woensdag 18 juli 2012 09:23:57 UTC+2 schreef Dirk Vranckaert het 
volgende:
>
> It always worked find to just pass the extras (in fact it's not only the 
> widget ID that i'm passing, there is some other stuff in there to..). It 
> since the launced activity starts another activity for result it doesn't 
> work anymore... So I guess using the extras or the data element won't make 
> a difference. I even tried to launch the activity without passing anything 
> and still my onActivityResult method is not reached...
>
> So what I currently do is nothing more than this (so without any extras):
> Intent intent = new Intent(ctx, activity);
> PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 
> widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
>
> So then what do you mean with create different actions?
>
> Do you mean to create different pendingIntents (so with a different 
> requestCode, something like "start" + widgetId and "stop" + widgetId) or do 
> you mean to create two different activities (cause that is whay I already 
> have, a start- and stop-activity)?
>
> Op woensdag 18 juli 2012 09:14:21 UTC+2 schreef TreKing het volgende:
>>
>> On Wed, Jul 18, 2012 at 2:13 AM, TreKing  wrote:
>>
>>> This makes each PendingIntent unique and they wrote overwrite each other
>>
>>
>> This makes each PendingIntent unique and they *won't* overwrite each 
>> other.
>>
>>
>> -
>> TreKing  - Chicago 
>> transit tracking app for Android-powered devices
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-18 Thread Dirk Vranckaert
It always worked find to just pass the extras (in fact it's not only the 
widget ID that i'm passing, there is some other stuff in there to..). It 
since the launced activity starts another activity for result it doesn't 
work anymore... So I guess using the extras or the data element won't make 
a difference. I even tried to launch the activity without passing anything 
and still my onActivityResult method is not reached...

So what I currently do is nothing more than this (so without any extras):
Intent intent = new Intent(ctx, activity);
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 
widgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);

So then what do you mean with create different actions?

Do you mean to create different pendingIntents (so with a different 
requestCode, something like "start" + widgetId and "stop" + widgetId) or do 
you mean to create two different activities (cause that is whay I already 
have, a start- and stop-activity)?

Op woensdag 18 juli 2012 09:14:21 UTC+2 schreef TreKing het volgende:
>
> On Wed, Jul 18, 2012 at 2:13 AM, TreKing  wrote:
>
>> This makes each PendingIntent unique and they wrote overwrite each other
>
>
> This makes each PendingIntent unique and they *won't* overwrite each 
> other.
>
>
> -
> TreKing  - Chicago 
> transit tracking app for Android-powered devices
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-18 Thread TreKing
On Wed, Jul 18, 2012 at 2:13 AM, TreKing  wrote:

> This makes each PendingIntent unique and they wrote overwrite each other


This makes each PendingIntent unique and they *won't* overwrite each other.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-18 Thread TreKing
On Wed, Jul 18, 2012 at 1:48 AM, Dirk Vranckaert
wrote:

> 1) I have a widget with a button, on the button I want to put the
> PendingIntent that I showed in my first post.
> 2) Then when the user presses that button, an action happens (something is
> started), and I want to change the PendingIntent on the button to something
> new (another activity and different extras) in order to create a 'stop'
> button
> 3) When the stop button is pressed I again change the PendingIntent to the
> one from step 1
>

I do pretty much the exact same thing with my widget. Instead of using
extras to pass the widget ID, use the Data element:

http://developer.android.com/reference/android/content/Intent.html#setData%28android.net.Uri%29

Or use two different actions ("start" and "cancel", for example). This
makes each PendingIntent unique and they wrote overwrite each other and you
won't need UPDATE_CURRENT.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-17 Thread Dirk Vranckaert
I do indeed need that.

What I'm trying to do is:
1) I have a widget with a button, on the button I want to put the 
PendingIntent that I showed in my first post.
2) Then when the user presses that button, an action happens (something is 
started), and I want to change the PendingIntent on the button to something 
new (another activity and different extras) in order to create a 'stop' 
button
3) When the stop button is pressed I again change the PendingIntent to the 
one from step 1

So to achieve that I found out that I have to use a PendingIntent, but or 
the id of the pending-intent I use the id of the widget (because per widget 
the user needs to be able to start the process). And I do that I have to 
use the FLAG_UPDATE_CURRENT, so the pending intent is updated (and not 
removed or whatever) when the user presses the button.
A second reason to use the FLAG_UPDATE_CURRENT is to not loose the 
PendingIntent when it's fired once. Whit this I mean when the user presses 
the button, he can still cancel his action (in the activity that opened he 
just presses the back button of the device). But doing this with the 
PendingIntent.FLAG_ONE_SHOT will make that when the user presses again that 
button on the widget my activity is no longer executed. Or should I do this 
another way...?

Op dinsdag 17 juli 2012 21:14:18 UTC+2 schreef TreKing het volgende:
>
> On Tue, Jul 17, 2012 at 8:35 AM, Dirk Vranckaert  > wrote:
>
>> However if I start it with the PendingIntent with the flag set to 
>> PendingIntent.FLAG_UPDATE_CURRENT part of my flow is not executed anymore
>>
>
> Why are you using UpdateCurrent? Do you have extras in the intent that 
> need to be updated?
>
>
> -
> TreKing  - Chicago 
> transit tracking app for Android-powered devices
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] PendingIntent launched from widget causes onActivityResult to not be called

2012-07-17 Thread TreKing
On Tue, Jul 17, 2012 at 8:35 AM, Dirk Vranckaert
wrote:

> However if I start it with the PendingIntent with the flag set to
> PendingIntent.FLAG_UPDATE_CURRENT part of my flow is not executed anymore
>

Why are you using UpdateCurrent? Do you have extras in the intent that need
to be updated?

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en