友!
我无法从其他活动中致电MapActivity
:
Intent nextScreen = new Intent(getApplicationContext(), MapScreen.class);
startActivity(nextScreen);
MapScreen.class
是public 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)
答案 0 :(得分:1)
使用
打开另一个活动的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) {