我在清单文件中写了这个权限:
</application>
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-feature android:name="android.hardware.wifi" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>
当我启动应用程序时,它写道:“不幸的是,应用程序停止了”并在 Logcat 中退出,我看到程序失败的行是:
Class conmanClass;
Field iConnectivityManagerField;
iConnectivityManagerField = conmanClass.getDeclaredField("mService");
有什么问题?谁能帮我解决它?
这是日志猫:
09-14 09:11:49.493: E/AndroidRuntime(1669): FATAL EXCEPTION: main
09-14 09:11:49.493: E/AndroidRuntime(1669): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.voicerecognitiondemo/com.example.voicerecognitiondemo.VoiceRecognitionDemo}: java.lang.NullPointerException
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.os.Looper.loop(Looper.java:137)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-14 09:11:49.493: E/AndroidRuntime(1669): at java.lang.reflect.Method.invokeNative(Native Method)
09-14 09:11:49.493: E/AndroidRuntime(1669): at java.lang.reflect.Method.invoke(Method.java:511)
09-14 09:11:49.493: E/AndroidRuntime(1669): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-14 09:11:49.493: E/AndroidRuntime(1669): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-14 09:11:49.493: E/AndroidRuntime(1669): at dalvik.system.NativeStart.main(Native Method)
09-14 09:11:49.493: E/AndroidRuntime(1669): Caused by: java.lang.NullPointerException
09-14 09:11:49.493: E/AndroidRuntime(1669): at com.example.voicerecognitiondemo.VoiceRecognitionDemo.onCreate(VoiceRecognitionDemo.java:55)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.Activity.performCreate(Activity.java:4465)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-14 09:11:49.493: E/AndroidRuntime(1669): ... 11 more