-2

Logcat 是:

 11-05 17:10:45.600: E/AndroidRuntime(7382):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2139)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.app.ActivityThread.access$700(ActivityThread.java:143)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.os.Handler.dispatchMessage(Handler.java:99)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.os.Looper.loop(Looper.java:137)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.app.ActivityThread.main(ActivityThread.java:4963)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at java.lang.reflect.Method.invokeNative(Native Method)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at java.lang.reflect.Method.invoke(Method.java:511)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at dalvik.system.NativeStart.main(Native Method)
    11-05 17:10:45.600: E/AndroidRuntime(7382): Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10126 nor current process has android.permission.ACCESS_NETWORK_STATE.
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.os.Parcel.readException(Parcel.java:1425)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.os.Parcel.readException(Parcel.java:1379)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.net.IConnectivityManager$Stub$Proxy.getAllNetworkInfo(IConnectivityManager.java:775)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.net.ConnectivityManager.getAllNetworkInfo(ConnectivityManager.java:511)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at com.androidhive.googleplacesandmaps.ConnectionDetector.isConnectingToInternet(ConnectionDetector.java:22)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at com.androidhive.googleplacesandmaps.MainActivity.onCreate(MainActivity.java:70)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.app.Activity.performCreate(Activity.java:5184)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2078)
    11-05 17:10:45.600: E/AndroidRuntime(7382):     ... 11 more
4

2 回答 2

1

有趣的部分在这里:

Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10126 nor current process has android.permission.ACCESS_NETWORK_STATE.

因此,您需要将权限添加到应用程序的清单中。

于 2013-11-05T13:56:19.113 回答
0

您需要添加

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

到你的 AndroidManifest.xml 然后它应该可以工作

于 2013-11-05T21:12:36.483 回答