Bonjour

Je souhaite utiliser un Intent pour lancer une application héritant de la classe MapActivity.

Pour le test, ma première application (Test) a un bouton qui lance via un Intent lance la deuxième application (TestView)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button bt = (Button)findViewById(R.id.Button01);
        bt.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(Test.this, TestView.class);
		        startActivity(intent);
			}
        });
    }
Tant que la deuxième application hérite de Activity, son lancement via un Intent ne pose aucun problème. Dès que j'hérite de la classe MapActivity, ca explose.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
public class TestView extends MapActivity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.testview);
	}
 
	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}
}
Pourtant j'ai mis à jour mon fichier XML pour rendre en compte la clé de MapView :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="MapView"></TextView>
 
<com.google.android.maps.MapView
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:apiKey="???????????????"
                 />
 
</LinearLayout>
Voici le message d'injure :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
10-12 16:46:14.422: ERROR/AndroidRuntime(24906): Uncaught handler: thread main exiting due to uncaught exception
10-12 16:46:14.432: ERROR/AndroidRuntime(24906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.test/com.android.test.MapView}: java.lang.RuntimeException: stub
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2375)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2486)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.app.ActivityThread.access$2100(ActivityThread.java:123)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1843)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.os.Looper.loop(Looper.java:123)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.app.ActivityThread.main(ActivityThread.java:4321)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at java.lang.reflect.Method.invokeNative(Native Method)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at java.lang.reflect.Method.invoke(Method.java:521)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at dalvik.system.NativeStart.main(Native Method)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906): Caused by: java.lang.RuntimeException: stub
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at com.google.android.maps.MapActivity.<init>(Unknown Source)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at com.android.test.MapView.<init>(MapView.java:7)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at java.lang.Class.newInstanceImpl(Native Method)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at java.lang.Class.newInstance(Class.java:1472)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2367)
10-12 16:46:14.432: ERROR/AndroidRuntime(24906):     ... 11 more
Une idée ?

merci d'avance