朋友们!

我无法通过其他活动致电MapActivity

Intent nextScreen = new Intent(getApplicationContext(), MapScreen.class);
startActivity(nextScreen);


其中MapScreen.classpublic class MapScreen extends MapActivity

错误消息是:

03-20 11:00:38.757: E/AndroidRuntime(31450): FATAL EXCEPTION: main
03-20 11:00:38.757: E/AndroidRuntime(31450): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.router.android/com.router.android.MapScreen}: java.lang.NullPointerException
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2081)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2106)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.access$700(ActivityThread.java:134)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1217)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.os.Looper.loop(Looper.java:137)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.main(ActivityThread.java:4856)
03-20 11:00:38.757: E/AndroidRuntime(31450): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 11:00:38.757: E/AndroidRuntime(31450): at java.lang.reflect.Method.invoke(Method.java:511)
03-20 11:00:38.757: E/AndroidRuntime(31450): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)

最佳答案

从另一个活动打开MapScreen类与

Intent nextScreen = new Intent(getApplicationContext(), MapScreen.class);
startActivity(nextScreen);


要么

Intent nextScreen = new Intent(this, MapScreen.class);
startActivity(nextScreen);


我认为问题出在您的MapScreen类中,必须具有onCreate()方法。

public class MapScreen extends MapActivity{

protected void onCreate(Bundle arg0) {


像这个示例类:
http://depaul-android-app.googlecode.com/svn/tags/0.0.1/src/edu/depaul/android/activities/MapScreen.java

07-24 09:49