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

Calling method in post delayed
Show only Locations Close to my Current Position within 10Kms
Android Studio 0.5.8 freezes on importing new project
Android App Preference
Deference between YouTubePlayerFragment and YouTubePlayerView
Create a database for another Android app
changing orientation workflow
How to run cordova music player in background with options available on notification bar
Another Unsatisfied Linker Error. Cannot find 'main'
Transparent AlertDialog Android
AsynTask and Service binding
How to add parent activity when browser is opened from notifications
Android Switch thumb image stretched
How to create a layout like this?
INSERT with SELECT SQL statement in Android
Null Pointer Exception in Android Code

Categories

HOME
gpu
jmx
themes
apache-spark-mllib
yahoo-finance
camera
knitr
scripting
web-hosting
limit
x264
extjs4.2
fabric.io
categorical-data
mod-security
windows-ce
ipmitool
filechannel
dynatrace
qsqlquery
bitnami
event-sourcing
sigma.js
database-connection
sar
simpleitk
string-concatenation
aggregation
fat
shared
corpus
mat
magento-1.8
dst
mustache
cart
playstation-portable
r-grid
mnist
sharepoint-workflow
hivemq
sim-toolkit
apic
graphhopper
sessionstorage
release
projects-and-solutions
mongoose-schema
linqpad
glm-math
tcc
x++
cnc
user-defined-fields
insight
java-bytecode-asm
subnet
oracleclient
reshape
trigger.io
rocks
visual-studio-2008-sp1
cubism.js
stax
resourcemanager
windows-azure-queues
freepbx
data-protection
aurora
boost-serialization
beanstalk
aspen
directdraw
qt5.2
vigenere
django-urls
page.js
evolus-pencil
lasso
haskell-warp
rdflib
typeconverter
snackbar
deform
formview
genymotion-call
psr-4
rmysql
verold
codeplex
jjaql
spring-remoting
observium
node-blade
pagedown
fragmenttransaction
xcode3.2
veracity
zope.interface
dajaxice
lambdaj
jquery-address
u2netdk
cgbitmapcontextcreate
w3c-geolocation
event-receiver
cuteeditor
appledoc
mtu
svk
squishit
cruisecontrol.rb
aspmenu
blender-2.49
qtabbar
strtod
dojo-dnd
change-management

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