Here you go:
<application android:icon="@drawable/icon"
     android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar"
    android:debuggable="true"
    android:allowTaskReparenting="true"
    android:name="com.company.product.AppName"
       >
           
        <activity 
    android:theme="@style/Theme.Sherlock"
        android:name="com.company.product.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        
        >

If you don't want singleTask there is a way to make sure singleTop always 
has only one instance. Just like Piren said - make sure there are no other 
intents to launch your app - they will create a different instance. If you 
absolutely need to have other intents that can launch your activity but 
still want only one instance use this:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | 
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
It won't be the same instance but there will be only one.
Good luck!



On Tuesday, April 23, 2013 12:10:12 AM UTC-7, Piren wrote:
>
> Sorry, you should probably try singleTask before singleInstance :)
>
> On Tuesday, April 23, 2013 10:08:49 AM UTC+3, Piren wrote:
>>
>> Sounds like the intent being used to launch the app by default and the 
>> intent used to launch from the icon behave differently. SingleTop does not 
>> guarantees that only one activity will be shown, rather one per task. 
>> sounds as if you keep creating different tasks in one instance.  I had 
>> something similar happen to me and it was specific to some Motorola based 
>> devices.. i guess their launcher treated launch intents a bit differently.
>>
>> If you can, change it to singleInstance. If not, try checking the 
>> different intents you use to launch and also see if enabling 
>> taskReparenting helps you.
>>
>> On Tuesday, April 23, 2013 2:49:13 AM UTC+3, Dritan wrote:
>>>
>>> I just noticed that even when I export the app with a debug key via 
>>> "ant debug" the app behaves the same way as OTA installation, which is 
>>> the incorrect behavior. 
>>>
>>> How come my app's main activity's "launchMode" stops behaving weirdly 
>>> AFTER it has run once? I don't have any code handling the activity 
>>> stack, I left it purely on Android's hands. 
>>>
>>> Any clues? 
>>>
>>> Thanks!! 
>>>
>>>
>>> On Apr 22, 6:52 pm, Dritan <djdea...@gmail.com> wrote: 
>>> > Hello, 
>>> > 
>>> > When I sideload my app to my phone via USB, the very first time it 
>>> > runs, the main activity behaves as expected. Only 1 instance of main 
>>> > can be launched, no matter what. 
>>> > 
>>> > When I export my app as a signed app, then install the app OTA the 
>>> > main activity behaves completely different ONLY the first time it 
>>> > runs. 
>>> > 
>>> > After installing the app, the main activity loads. I press the 'Home' 
>>> > button, then relaunch the app from the icon and a new main activity is 
>>> > loaded. I can keep on doing this for tens of hundreds of activity 
>>> > instances. 
>>> > 
>>> > Once I have closed all such lose instances and restart the app, then 
>>> > the main activity returns the expected behavior as being a "singleTop" 
>>> > instance. 
>>> > 
>>> > I have removed all proguard-related lines and files from my app so 
>>> > when I export as signed, doesn't try to obfuscate? (to my knowledge) 
>>> > 
>>> > I do not understand why this is happening, is this a bug with Android 
>>> > or am I doing something I have never heard of before? Does anyone have 
>>> > a solution? 
>>> > 
>>> > Thank you, 
>>> > Dritan 
>>>
>>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to