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. Possibility to access the Own Content Provider

Hi All,

I've accessed existing Content Provider. ie, I've retrieved data from
Contacts Application by including the Permission <Read_Contacts>
within my application Android Manifest file.

I've created new Content Provider by extending my class from Content
Provider. I've overridded the method query(), delete(), update() &
getType(). For that, I've included <provider> within AndroidManifest

Now I would like to access my own content provider in another
application. For this, I've tried the following code :


import android.content.ContentUris;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import; // TO ACCESS MY

public class OwnProviderAccessActivity extends ListActivity {
        private ListAdapter mAdapter;

        Uri uri = WikiNote.Notes.ALL_NOTES_URI;
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        String auth = WikiNote.Notes.ALL_NOTES_URI.getAuthority();
 // Note the below line
Cursor C = getContentResolver().query(WikiNote.Notes.ALL_NOTES_URI,
null, null, null, null);
// Here I've accessed one coulmn from the table in OwnContentProvider
        String[] columns = new String[] {WikiNote.Notes.TITLE};
        int[] names = new int[] {};
                mAdapter = new SimpleCursorAdapter(this, R.layout.contacts, C,
columns, names);


        protected void onListItemClick(ListView l, View v, int position, long
id) {
                super.onListItemClick(l, v, position, id);

I've got output by adding OWNCONTENTPROVIDER application within

Here the source of entire OWNCONTENTPROVIDER application will be
inclueded within the my  OWNPROVIDERACCESS application. I would like
to achieve the same thing using <permission> like Accessing Existing
Content Provider.

Please give your answers... I was totally confused .... I've stuck
with this issue.

Any kind of reply will be appreciated!!!

Thanks in Advance!!!

2. How to open new sub activity by item of ListView......

I want to set SubActivity on the item of ListView.please guide me how
i do it...i am new in android......


3. HessianProxyFactory Problem

4. ADT - Eclipse

5. Seek Bar Problem

6. Cool Apps for weddings

7. Utterly confounded trying to create horizontal scrolling