How to solve the problem of launch the apps twice or more?

by Kenneth WON » Wed, 21 Apr 2010 02:30:18 GMT

Sponsored Links
 Hi, all,

I am a new Android apps developer, I suffer a problem that I don't
know how to solve. Can anyone give me some suggestion?
The problem is the apps will launch twice or more when I apply the
following steps:
1. launch the app A (1 time)
2. rotate the screen, (the app A will launch again, now the app A
launch twice)
3. press return button (my expected result is that the app A will keep
running, luckily, I can do that.)
4. launch the app A ( there will be one more app A running)

So, in this case, there are 3 app A launching at the same time.
But my expected result is just have one and only one app A launch.

Thank you!


How to solve the problem of launch the apps twice or more?

by ~ TreKing » Wed, 21 Apr 2010 04:38:54 GMT #lmode
< #lmode>
TreKing - Chicago transit tracking app for Android-powered devices 


Sponsored Links

How to solve the problem of launch the apps twice or more?

by Kenneth WON » Wed, 21 Apr 2010 10:08:03 GMT

 Hi, thank you for your help!
But I tried to add android:launchMode="singleTask" or
android:launchMode="singleInstance" in the <activity> before, but it
seems not work.
The app still running twice or more at the same time by rotate screen
or press return button, and launch the app.


How to solve the problem of launch the apps twice or more?

by Kenneth WON » Wed, 21 Apr 2010 12:05:36 GMT

 Hi, Dianne Hackborn,

Thank you!
In the main activity, I will start a service, so I am calling
startService() in onCreate().
Is that not necessary?

> > >

How to solve the problem of launch the apps twice or more?

by Nithin » Wed, 21 Apr 2010 13:09:39 GMT

 I also face the same problem, what I did was in manifest, inside
activity, just included
android:launchMode="singleTop" and its working fine.

What "singleTop" will do is,

The "standard" and "singleTop" modes differ from each other in just
one respect: Every time there's new intent for a "standard" activity,
a new instance of the class is created to respond to that intent. Each
instance handles a single intent. Similarly, a new instance of a
"singleTop" activity may also be created to handle a new intent.
However, if the target task already has an existing instance of the
activity at the top of its stack, that instance will receive the new
intent (in an onNewIntent()  call); a new instance is not created. #lmode


> > > >

How to solve the problem of launch the apps twice or more?

by Kenneth WON » Wed, 21 Apr 2010 14:24:33 GMT

 The purpose of this app is to run the service forever until shutdown
the phone, and after the user leaves the app and return later, the
service will not launch again, means only have one of this service
Now, the problem is it can't only have one of this service running.
Do I need adding something in AndroidManifest.xml file, the class that
extends Activity class or the class that extends Service class?

> > > > >

Other Threads

1. Eclipse and shell have separate avd dirs - how to fix?

On Mac OS 10.6.4, I've installed Android SDK, plus Eclipse 3.5 and
Android plugins.

- My SDK is installed at ~/android-sdk-mac_86
- The tools folder of the SDK is added to my bash PATH env var.
- I've set up the SDK/AVD manager within Eclipse, pointing it to my ~/
android-sdk-mac_86 folder.

Everything is working properly, except for one thing.  Eclipse and the
command-line SDK tools cannot agree on where to store my AVD files.

The SDK/AVD manager within Eclipse places my avds under ~/.android/
avd, which is the expected location according to the SDK docs.  But
when I run the 'android' AVD manager from the shell, it looks for AVDs
under ~/android-sdk-mac_86/.android/avd.

The 'emulator' command, when run from Eclipse, uses the AVDs in
~/.android/avd, as expected.  Emulator when run from the shell, sees
only AVDs created in the ~/android-sdk-mac_86/.android/avd folder.

Can someone tell me how to reconfigure the shell-based tools to use
the ~/.android/avd folder, so I can get everything in one place?



2. SIM prabayar yang bagus?

Hai teman-teman... saya mau pilih SIM yang cocok untuk data di
Android. Saya:
* kadang di luar Indonesia dan nggak mau bayar terus... jadi mau
prabayar, mungkin harian atau mingguan
* biasanya di kota, kadang di luar. kalau punya SIM prabayar.
* mau yang cepat kl bisa.
* batas download tidak harus besar banget (tapi kalau kebetulan giga-
an, bagus juga)

Ada saran? Saya dengar Axis dan IM3 cukup bagus dan murah, tapi belum
tahu sendiri.

Makasih, dan mohon maaf diganggu. Saya coba baca-baca email yang lama
tapi belum ketemu informasi yang saya cari. (Saya orang Australia dan
hanya bisa membaca agak pelan kalau Bahasa Indonesia).

Oh ya, dan sebagai kenalan... saya mau beli HP Android waktu ke
Singapura tengah Juli. Udah nggak sabar, masih pake Nokia yang sangat
kuno :-).

Makasih banyak,

"Indonesian Android Community [id-android]" 

3. How to make a imageview at right of linearlayout

4. A clear, concise tutorial on PreferenceActivity & Preferences?

5. CheckedTextView - only can select once checkbox

6. Unable to Connect to FTP server and upload a file

7. PreferenceActivity and appWidgetId relation