由于gps权限被拒绝,android 4.4上的android应用程序崩溃 [英] android app crash on android 4.4 due to gps permission denial

查看:118
本文介绍了由于gps权限被拒绝,android 4.4上的android应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在android 4.4 (Kitkat)上启用GPS时,我的android应用程序崩溃.在Android 4.3之前一直运行良好. 我正在使用以下代码打开GPS

My android app is crashing when I try to enable GPS on my android 4.4 (Kitkat). It's been working fine till Android 4.3 . I am using following code to turn on GPS

Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
this.sendBroadcast(intent);

在我的Log Cat中,它提供了安全例外.

In my Log Cat its giving security exception.

我的LogCat详细信息如下:-

My LogCat details are as :-

11-27 12:47:37.410: E/AndroidRuntime(3818): Caused by: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.location.GPS_ENABLED_CHANGE from pid=3818, uid=10084
11-27 12:47:37.410: E/AndroidRuntime(3818):  at android.os.Parcel.readException(Parcel.java:1461)
11-27 12:47:37.410: E/AndroidRuntime(3818):  at android.os.Parcel.readException(Parcel.java:1415)
11-27 12:47:37.410: E/AndroidRuntime(3818):  at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:2373)
11-27 12:47:37.410: E/AndroidRuntime(3818):  at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1127)
11-27 12:47:37.410: E/AndroidRuntime(3818):  at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:365)
11-27 12:47:37.410: E/AndroidRuntime(3818):  at com.sus.SUSV7_1.Activity.Splash_ScreenActivity.turnGPSOn(Splash_ScreenActivity.java:66)
11-27 12:47:37.410: E/AndroidRuntime(3818):  at com.sus.SUSV7_1.Activity.Splash_ScreenActivity.onCreate(Splash_ScreenActivity.java:26)

当我注释代码时,它可以正常工作.是否有任何特定参数可以在Android 4.4上手动启用GPS.

When I comment the code then its working fine. Is there any specific parameter to enable GPS manually on Android 4.4.

推荐答案

这决不是公开API.

关于此主题的AOSP错误跟踪器上甚至存在一个问题: https://code.google.com/p/android/issues/detail ?id = 35924

There even is an issue on AOSP bug tracker regarding this topic: https://code.google.com/p/android/issues/detail?id=35924

我想,他们只是解决了整个安全问题.

I guess, they just fixed this security whole.

您可能要指示用户更改GPS设置:

You might want to direct the user to change the GPS settings:

startActivity(context, new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));

这篇关于由于gps权限被拒绝,android 4.4上的android应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆