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
答案 0 :(得分:1)
有趣的部分在这里:
Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10126 nor current process has android.permission.ACCESS_NETWORK_STATE.
因此,您需要将权限添加到应用程序的清单中。
答案 1 :(得分:0)
您需要添加
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
到你的AndroidManifest.xml然后它应该工作