gpt4 book ai didi

android - 如何打开GPS

转载 作者:搜寻专家 更新时间:2023-11-01 07:40:26 27 4
gpt4 key购买 nike

这些是我打开GPS的代码


LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.setTestProviderEnabled("gps", true);

和我的xml中的权限


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

但应用程序崩溃了。


01-07 10:41:35.104: ERROR/AndroidRuntime(1823): java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure setting
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Parcel.readException(Parcel.java:1218)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Parcel.readException(Parcel.java:1206)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.location.ILocationManager$Stub$Proxy.setTestProviderEnabled(ILocationManager.java:952)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.location.LocationManager.setTestProviderEnabled(LocationManager.java:1054)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.hisoft.battery.MainActivity.connGPS(MainActivity.java:118)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.hisoft.battery.MainActivity.access$2(MainActivity.java:114)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.hisoft.battery.MainActivity$2.onClick(MainActivity.java:62)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.View.performClick(View.java:2364)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.View.onTouchEvent(View.java:4179)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.widget.TextView.onTouchEvent(TextView.java:6607)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.View.dispatchTouchEvent(View.java:3709)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Looper.loop(Looper.java:123)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at java.lang.reflect.Method.invoke(Method.java:521)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at dalvik.system.NativeStart.main(Native Method)

谁知道为什么?

最佳答案

这里只是猜测:转到设置 > 应用程序 > 开发 > 允许模拟位置,并确保选中它。

关于android - 如何打开GPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4622131/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com