gpt4 book ai didi

Android:从 Activity 类调用 MapActivity Mapquest

转载 作者:行者123 更新时间:2023-11-30 03:00:57 24 4
gpt4 key购买 nike

friend 们!

我无法从其他 Activity 调用 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)

最佳答案

从另一个 Activity 打开 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

关于Android:从 Activity 类调用 MapActivity Mapquest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22547322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com