Mark Wyszomierski wrote:
> Hi,
> 
> I'm using an intent-filter on URLs for my activity:
> 
> <activity
>   android:name=".ActivityTest"
>   android:launchMode="singleTop"
>   >
>   <intent-filter><action android:name="android.intent.action.VIEW"></
> action>
>     <category android:name="android.intent.category.DEFAULT"></
> category>
>     <category android:name="android.intent.category.BROWSABLE"></
> category>
>     <data android:host="www.mysite.com" android:scheme="http"></data>
>   </intent-filter>
> </activity>
> 
> the launchMode attribute is set to "singleTop", but it looks like a
> new activity is created every time I click a matching url. I thought
> that if the activity is already alive somewhere, it would simply be
> brought to the front of my activity stack?
> 
> I tried this on the emulator/device, same behavior, a new activity
> instance is always created,

"For the "singleTop" mode, an existing instance of the class is re-used
to handle a new intent if it resides at the top of the activity stack of
the target task. If it does not reside at the top, it is not re-used.
Instead, a new instance is created for the new intent and pushed on the
stack. "

and

"Which task will hold the activity that responds to the intent. For the
"standard" and "singleTop" modes, it's the task that originated the
intent (and called startActivity()) — unless the Intent object contains
the FLAG_ACTIVITY_NEW_TASK flag."

and

"A "standard" or "singleTop" activity can be instantiated many times.
They can belong to multiple tasks, and a given task can have multiple
instances of the same activity. "

(all from
http://developer.android.com/intl/de/guide/topics/fundamentals.html)

Hence, if you are launching these from multiple tasks, I can certainly
see getting the behavior you specify. Or, if your activity is not at the
top of the activity stack for its task, you will get this behavior.

(and, yes, this stuff makes my head hurt, too...)

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 8-12 February 2010: http://bignerdranch.com

-- 
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

Reply via email to