Device: Nexus One
Firmware: 2.1 update 1
Platform 2.1, API: 7

I have seen it mentioned before that there's a difference between
installing an app via Eclipse and via adb, but I need more
clarification.

I have an app that starts a voice recognition activity in the main
activity's onStart() method..  I'm planning to run this app from a
Nexus One connected to a laptop via USB.  I want this app to launch
perhaps 100 times, each time restarting the voice recognition
activity.

When I install the app onto the Nexus One via Eclipse, I notice this
behavior:
- when the app is launched from the command line via "adb shell am
start -a android.intent.action.MAIN -n com.voice/com.voice.VoiceSearch
$1", the app runs with the voice recognition activity restarting each
time.  This is the behavior I want.
- I also notice that after the app has run, I hit Home, then click on
the app from the screen, the app will be in its last state, and the
voice recognition activity will not restart.  I specified
finishOnTaskLaunch="true" in the manifest, so I thought the voice
recognition activity would restart.

When I package an app as per instructions and install it onto the
device via adb install, I get this behavior:
- when the app is launched from the command line, the voice
recognition app will run the first time, but subsequent launches do
not restart the voice recognition activity.   The voice recognition
activity just stays in its last state.   I get the following message:
Warning: Activity not started, its current task has been brought to
the front

- I also notice that after the app has run, I hit Home, then click on
the app from the screen, the app will restart the voice recognition
activity.  By the way, this happens whether or not I have
finishOnTaskLaunch="true" set in the manifest or not.

What do I need to do so that I can launch the app from the command
line via adb lots of times with the voice recognition activity
restarting each time?

I call this from the main activity's onStart():

    private void startVoiceRecognitionActivity() {
        Intent intent= new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say something!");
        startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
        waitForResults();
    }

Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.audience.android.voice"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".VoiceSearch"
                  android:finishOnTaskLaunch="true"
                  android:clearTaskOnLaunch="true"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.INTERNET" /
>
</manifest>

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