简体   繁体   English

Android 工作室 java.lang.SecurityException:需要 INSTALL_LOCATION_PROVIDER 权限

[英]Android studio java.lang.SecurityException: need INSTALL_LOCATION_PROVIDER permission

I am working on android studio.我正在 android 工作室工作。 I am getting live GPS coordinates on a mobile app.我在移动应用程序上获得实时 GPS 坐标。 On every mobile device, the coordinates are generated but a single mobile is not working and giving zero(0) coordinates having android version 9 .在每个移动设备上,都会生成坐标,但单个移动设备无法正常工作,并给出具有 android 版本9zero(0)坐标。 Below is my code下面是我的代码

@SuppressLint("MissingPermission")
 public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext
                .getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager
                .isProviderEnabled(LocationManager.GPS_PROVIDER);

        // getting network status
        isNetworkEnabled = locationManager
                .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        } else {
            this.canGetLocation = true;
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network");
                if (locationManager != null) {
                    location = locationManager
                            .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();
                    }
                }
            }
            // if GPS Enabled get lat/long using GPS Services
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(
                            LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("GPS Enabled", "GPS Enabled");
                    if (locationManager != null) {
                        location = locationManager
                                .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();
                        }
                    }
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return location;
}

Gradle Gradle

android {
compileSdkVersion 33
defaultConfig {
    applicationId "com.example.wrflhr.wrfnanbookings"
    minSdkVersion 19
    targetSdkVersion 33
    versionCode 3
    versionName "3.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true

}
buildTypes {
    release {
        minifyEnabled false
        debuggable false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

How to get rid of this issue?如何摆脱这个问题? I have been stuck for so many days Any help would be highly appreciated.我被困了这么多天任何帮助将不胜感激。

android.permission.INSTALL_LOCATION_PROVIDER permission falls under the system or signed permissions which means only system applications can request this permission. android.permission.INSTALL_LOCATION_PROVIDER权限属于系统或签名权限,这意味着只有系统应用程序可以请求此权限。

Only OEMs are allowed to install a new location provider.只允许 OEM 安装新的位置提供程序。 A third-party developer cannot grant to his/her application the permission required to install a new location provider (android.permission.INSTALL_LOCATION_PROVIDER).第三方开发人员无法向他/她的应用程序授予安装新位置提供程序 (android.permission.INSTALL_LOCATION_PROVIDER) 所需的权限。 Read Thread读线程

According to the documentation根据文档

Allows an application to install a location provider into the Location Manager.允许应用程序将位置提供程序安装到位置管理器中。

Not for use by third-party applications.不供第三方应用程序使用。

Constant Value: "android.permission.INSTALL_LOCATION_PROVIDER"常数值:“android.permission.INSTALL_LOCATION_PROVIDER”

In order to request this permission you have to sign your app as a system app.为了请求此权限,您必须将您的应用程序签名为系统应用程序。 See How怎么看

In order to install a new location provider either you have to root your android device or you have to develop a whole new firmware.为了安装新的位置提供程序,您必须对 android 设备进行 root,或者必须开发一个全新的固件。 Read Thread读线程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android GoogleMaps在某些设备上不工作,显示java.lang.SecurityException:需要INSTALL_LOCATION_PROVIDER权限 - Android GoogleMaps not working on some devices shows java.lang.SecurityException: need INSTALL_LOCATION_PROVIDER permission Java.lang.SecurityException:Android中的安全权限? - Java.lang.SecurityException:SECURE PERMISSION in android? 由以下原因引起:java.lang.SecurityException:“被动”位置提供者需要ACCESS_FINE_LOCATION权限 - Caused by: java.lang.SecurityException: “passive” location provider requires ACCESS_FINE_LOCATION permission java.lang.SecurityException:“被动”位置提供者需要API级别26的ACCESS_FINE_LOCATION权限 - java.lang.SecurityException: “passive” location provider requires ACCESS_FINE_LOCATION permission on API level 26 java.lang.SecurityException:提供者gps需要ACCESS_FINE_LOCATION权限 - java.lang.SecurityException: Provider gps requires ACCESS_FINE_LOCATION permission java.lang.SecurityException:需要 android.permission.BLUETOOTH_CONNECT 权限以获得 AttributionSource - java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for AttributionSource java.lang.SecurityException: UID 10243 在 Android 10 中没有粗略/精细定位权限 - java.lang.SecurityException: UID 10243 does not have Coarse/Fine Location permission in Android 10 Android:java.lang.SecurityException - Android: java.lang.SecurityException java.lang.SecurityException:权限被拒绝 - java.lang.SecurityException: Permission denied java.lang.SecurityException:权限拒绝错误 - java.lang.SecurityException: Permission Denial ERROR
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM