Android的 - 在Android 4.1.1 Settings.ACTION_DEVICE_INFO_SETTINGS崩溃Android、ACTION_DEVICE_INFO_SETTINGS、

2023-09-12 04:50:19 作者:初心未变

我有一个应用程序,用户可以在我的应用程序点击某个按钮,它会推出具体的设置页面从Android的用户。我采用的是Android API从他们的网站 http://developer.android.com/reference /android/provider/Settings.html

I have an app where users can click on certain buttons in my app and it will launch specific settings page from Android to the user. I uses the android API from their website http://developer.android.com/reference/android/provider/Settings.html

Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);  
                    currentContext.startActivity(intent);

Intent intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS);   
                    currentContext.startActivity(intent);

这些都是一些设置页面,我的应用程序将打开。到目前为止,我没有问题,从我的应用程序启动这两个意图。然而,当我尝试推出了关于平板电脑页面下方的code,设置进程崩溃。

These are some of the settings pages that my app will open. So far I have no problem launching these two intents from my app. However, when I try to launch the "About tablet" page with the code below, the Settings process crashes.

Intent intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);   
                    currentContext.startActivity(intent);

据崩溃在Android 4.1.1,但它工作正常,在Android 3.2。我还是新的Andr​​oid和我在为什么它崩溃丢失。我是新来的StackOverflow为好。希望我能在这里得到一些答案,很高兴见到大家。

It crashes on android 4.1.1 but it works fine on android 3.2. I'm still new to Android and I am at a lost on why it crashes. I'm new to StackOverflow as well. Hopefully I am able to get some answers here and nice to meet you all.

下面是我的logcat:

Here's my logcat:

09-19 09:50:12.830: I/ActivityManager(270): START {act=android.settings.DEVICE_INFO_SETTINGS cmp=com.android.settings/.Settings$DeviceInfoSettingsActivity u=0} from pid 1627
09-19 09:50:12.910: D/dalvikvm(270): GC_FOR_ALLOC freed 738K, 13% free 11824K/13575K, paused 62ms, total 62ms
09-19 09:50:13.010: W/System.err(1675): Removed 2131231183
09-19 09:50:13.020: W/System.err(1675): Removed 2131231190
09-19 09:50:13.060: D/LocalBluetoothProfileManager(1675): LocalBluetoothProfileManager construction complete
09-19 09:50:13.060: D/AndroidRuntime(1675): Shutting down VM
09-19 09:50:13.060: W/dalvikvm(1675): threadid=1: thread exiting with uncaught exception (group=0x40d4c300)
09-19 09:50:13.060: E/AndroidRuntime(1675): FATAL EXCEPTION: main
09-19 09:50:13.060: E/AndroidRuntime(1675): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.Settings$DeviceInfoSettingsActivity}: java.lang.NullPointerException
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.os.Looper.loop(Looper.java:137)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.ActivityThread.main(ActivityThread.java:4745)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at java.lang.reflect.Method.invokeNative(Native Method)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at java.lang.reflect.Method.invoke(Method.java:511)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at dalvik.system.NativeStart.main(Native Method)
09-19 09:50:13.060: E/AndroidRuntime(1675): Caused by: java.lang.NullPointerException
09-19 09:50:13.060: E/AndroidRuntime(1675):     at com.android.settings.Settings.onCreate(Settings.java:167)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.Activity.performCreate(Activity.java:5008)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
09-19 09:50:13.060: E/AndroidRuntime(1675):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
09-19 09:50:13.060: E/AndroidRuntime(1675):     ... 11 more
09-19 09:50:13.090: W/ActivityManager(270):   Force finishing activity com.android.settings/.Settings$DeviceInfoSettingsActivity
09-19 09:50:13.090: W/ActivityManager(270):   Force finishing activity com.panasonic.tbexperience/.view.templates.TwoColumnsControlActivity
09-19 09:50:13.100: W/InputMethodManagerService(270): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41811de8 attribute=null
09-19 09:50:13.130: D/dalvikvm(1675): GC_CONCURRENT freed 187K, 4% free 6233K/6471K, paused 12ms+5ms, total 60ms
09-19 09:50:13.610: W/ActivityManager(270): Activity pause timeout for ActivityRecord{417ea2e0 com.android.settings/.Settings$DeviceInfoSettingsActivity}
09-19 09:50:13.820: D/dalvikvm(445): GC_FOR_ALLOC freed 1020K, 33% free 14790K/22023K, paused 41ms, total 41ms
09-19 09:50:13.960: D/dalvikvm(445): GC_FOR_ALLOC freed 1057K, 30% free 15633K/22023K, paused 39ms, total 39ms
09-19 09:50:14.010: D/dalvikvm(445): GC_FOR_ALLOC freed 362K, 24% free 16871K/22023K, paused 32ms, total 32ms
09-19 09:50:14.060: D/dalvikvm(445): GC_CONCURRENT freed 1289K, 20% free 17622K/22023K, paused 3ms+7ms, total 39ms
09-19 09:50:14.060: D/dalvikvm(445): WAIT_FOR_CONCURRENT_GC blocked 29ms
09-19 09:50:14.060: D/dalvikvm(445): WAIT_FOR_CONCURRENT_GC blocked 17ms
09-19 09:50:14.100: D/dalvikvm(445): GC_FOR_ALLOC freed 1693K, 25% free 16723K/22023K, paused 31ms, total 31ms
09-19 09:50:14.190: D/dalvikvm(445): GC_CONCURRENT freed 1126K, 21% free 17585K/22023K, paused 14ms+9ms, total 64ms
09-19 09:50:14.190: D/dalvikvm(445): WAIT_FOR_CONCURRENT_GC blocked 50ms
09-19 09:50:14.390: I/dalvikvm(270): Jit: resizing JitTable from 8192 to 16384
09-19 09:50:16.870: I/Process(1675): Sending signal. PID: 1675 SIG: 9
09-19 09:50:16.890: I/ActivityManager(270): Process com.android.settings (pid 1675) has died.
09-19 09:50:16.890: W/ActivityManager(270): Force removing ActivityRecord{4166f668 com.android.settings/.Settings$DeviceInfoSettingsActivity}: app died, no saved state
09-19 09:50:16.890: W/InputMethodManagerService(270): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@415f2878 attribute=null
09-19 09:50:32.250: D/dalvikvm(1552): GC_CONCURRENT freed 424K, 9% free 6942K/7559K, paused 12ms+3ms, total 39ms

另外,我试图直接设置类名该API ...

Also, I tried to directly set the classname for this api...

Intent intent = new Intent();   
                    intent.setClassName("com.android.settings", "com.android.settings.Settings$DeviceInfoSettingsActivity");
                    currentContext.startActivity(intent);

同样的事情happens.It作品为Android 3.2,但在4.1.1不起作用。我已经得到了,也许我没有得到正确的类名4.1.1版本的感觉。有谁知道直接的类名称,打开关于平板电脑页面或是否有可能以编程方式打开该网页?

Same thing happens.It works for android 3.2 but doesn't work in 4.1.1. I've got a feeling that maybe I did not get the right class name for the 4.1.1 version. Does anyone know the direct class name to open the "About Tablet" page or whether is it possible to open that page programmatically?

问候, 舒文

推荐答案

Android的API文档说:

android api doc say:

In some cases, a matching Activity may not exist, so ensure you safeguard against this.

所以,你应该检查这个意图或自己赶上这个异常。

so you should check this intent or catch this exception yourself.