android


How to get the status of location access permission to warn user


How can I detect the status of location access when user rejected the permission in the permission manager of the app.
this is not about Android M,but all the API Level
I tried to use Context#checkPermission,but it always return true.so i can't get the right status of location access permission if the user rejected it.
private static boolean checkPermission(Context context, String permName, String pkgName){
PackageManager pm = context.getPackageManager();
if(PackageManager.PERMISSION_GRANTED == pm.checkPermission(permName, pkgName)){
System.out.println(pkgName + "has permission : " + permName);
return true;
}else{
//PackageManager.PERMISSION_DENIED == pm.checkPermission(permName, pkgName)
System.out.println(pkgName + "not has permission : " + permName);
return false;
}
}
Using ContextCompat.checkSelfPermission() has worked for me:
if(ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED){
return true;
}else{
Log.d(LOG_TAG, "Permission not granted: " + permission);
return false;
}

Related Links

What is happening in Android when i run Thread.sleep in background service
How to call functions from a custom base adapter
background color of custom notification with image buttons is black in 3.1 emulator
How do I connect a Lenovo IdeaPad S6000 to Ubuntu and Android SDK
Syntax error on token “/”, Expression expected after this token
Android - How to resume fragment from back stack if it exist?
Get next value from Cursor in Android
Getting working Scala Android Project under SBT
Eclipse / Android - how to monitor device's HTTP traffic
Android animation and layout stretch
Set the text in ImageButton
Calculate angle of touched point and rotate it on a fixed image or canvas or bitmap image in Android
Questions regarding Set as Ringtone Android
Android device to detect display is on or off using the hdmi cable
Rails send_data for a mobile device
Android java.lang.RuntimeException Null Pointer Exception SQLite LocalDB

Categories

HOME
sonarqube
notepad++
beautifulsoup
solaris
solver
shiro
vscode-extensions
pdfbox
opendj
settings
mapbox
google-admin-sdk
boto3
fosrestbundle
filechannel
shared-libraries
docx
intershop
mathprog
feathersjs
asp.net-mvc-viewmodel
pyramid
microsoft-ocr
dpdk
dynamically-generated
roundup
google-api-client
pylons
delimiter
android-things
wcag
datastax-enterprise-graph
user-defined-functions
dst
zend-debugger
left-join
sql-server-2000
catch-unit-test
contacts
html-encode
least-squares
servicestack-text
video-capture
apic
demo
jvmti
news
numberpicker
plaintext
x++
getchar
term
sonarlint-eclipse
chai-as-promised
payara-micro
colorbar
filehandle
payload
trigger.io
rxtx
angular2-testing
reporting-services-2012
ziparchive
spring-cloud-feign
model-associations
delta
respondcms
refinerycms
embedding
google-query-language
yajsw
lz77
fink
phpgrid
highland.js
jbase
nsurlsessiondatatask
cakephp-2.7
dot.js
android-vibration
raygun
ios8-extension
rfc5322
gd-graph
dtmf
hidapi
mongohq
asdf
android-loadermanager
panda3d
xcode3.2
inkcanvas
multiplexing
saxparseexception
automationelement
rmdir
mbeans
umra
inline-formset
django-paypal
codebase
load-time
blender-2.49
duplex
murmurhash
data-mapping
wysiwym
technical-debt

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App