I have a small application that uses two activities. Both the activities 
inherit from MapActivity and display a map (com.google.android.maps). 

Since the Android Google Map documentation says:

Only one MapActivity is supported per process. Multiple MapActivities 
running simultaneously are likely to interfere in unexpected and undesired 
ways.

I modified my manifest to run the two activities in two different processes 
(I have removed some lines to make it short):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
    package="com.example.myapp">

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" 
/>
    <uses-permission 
android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Light">

        <uses-library android:name="com.google.android.maps" />

        <activity 
            android:name=".Activity1"
            android:process=".Activity1">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>Unit
        </activity>

        <activity
            android:name=".Activity2"
            android:process=".Activity2">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

    <uses-sdk android:minSdkVersion="8" />
</manifest> 

Now the application runs fine but I have problems when I what to run Unit 
Tests on both the Activities.
For example:

package com.example.myapp;
public class Activity1Test extends 
ActivityInstrumentationTestCase2<Activity1> {

  Activity1 mActivity;
    
    public Activity1Test() {
        super("com.example.myapp.Activity1", Activity1.class);
    }

    @Override 
    protected void setUp() throws Exception {
        super.setUp();
        setActivityInitialTouchMode(false);
        setActivityIntent(new Intent());
        mActivity = getActivity();        //An exception is thrown at this 
line
    }
}

When I call the getActivity() method an exception is thrown:

java.lang.RuntimeException: Intent in process com.example.myapp resolved to 
different process .Activity1: Intent { flg=0x10000000 
cmp=com.example.myapp/.Activity1 }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:377)
at 
android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:119)
at 
android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:100)
at com.example.myapp.Activity1Test.setUp(Activity1Test.java:28)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

Is there a way to make the Unit Test to attach to the correct process?


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