我正在我的应用程序中启动Settings.ACTION_DEVICE_INFO_SETTINGS
意图。除了 4.1.2 和 4.2 之外,它适用于我所拥有的大多数设备。每当我尝试在此设备中启动上述意图时,设置应用程序将被强制关闭,并且还会导致我的应用程序停止运行。
启动Settings.ACTION_DEVICE_INFO_SETTINGS intent
之前有什么办法可以检查吗?或者至少可以阻止我的申请停止?
我已经尝试将startActivity(Intent)
放在try-catch块中。但这不是问题所在,因为设置活动存在并且在执行onCreate()
时崩溃。
这是堆栈跟踪:
08-14 17:38:37.984: E/AndroidRuntime(9905): FATAL EXCEPTION: main
08-14 17:38:37.984: E/AndroidRuntime(9905): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.Settings$DeviceInfoSettingsActivity}: java.lang.NullPointerException
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2062)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2087)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.ActivityThread.access$600(ActivityThread.java:133)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1198)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.os.Looper.loop(Looper.java:137)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.ActivityThread.main(ActivityThread.java:4803)
08-14 17:38:37.984: E/AndroidRuntime(9905): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 17:38:37.984: E/AndroidRuntime(9905): at java.lang.reflect.Method.invoke(Method.java:511)
08-14 17:38:37.984: E/AndroidRuntime(9905): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
08-14 17:38:37.984: E/AndroidRuntime(9905): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
08-14 17:38:37.984: E/AndroidRuntime(9905): at dalvik.system.NativeStart.main(Native Method)
08-14 17:38:37.984: E/AndroidRuntime(9905): Caused by: java.lang.NullPointerException
08-14 17:38:37.984: E/AndroidRuntime(9905): at com.android.settings.DeviceInfoSettings.onCreate(DeviceInfoSettings.java:98)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:796)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.BackStackRecord.run(BackStackRecord.java:635)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.Activity.performStart(Activity.java:5017)
08-14 17:38:37.984: E/AndroidRuntime(9905): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
08-14 17:38:37.984: E/AndroidRuntime(9905): ... 11 more
08-14 17:38:37.984: W/ActivityManager(658): Force finishing activity com.android.settings/.Settings$DeviceInfoSettingsActivity
答案 0 :(得分:0)
在启动Settings.ACTION_DEVICE_INFO_SETTINGS意图之前,有什么办法可以检查吗?
不幸的是,不,因为Intent
正在运行 - 您正在绊倒这些设备上的“设置”应用中的一些错误。
或者至少可以阻止我停止申请?
此崩溃对您的应用程序不应有任何影响。设置应用程序崩溃了,而不是你。崩溃对话框将显示在您的应用上,但您的应用应该不会受到影响。