Enable/Diasble Using “user location” programmatically in android

I want to use user's location in my android app. But I want the user to allow the app to use the user's location. So I want to have a dialog asking for user's permission to use the location when the user starts the app.

To use the location I know I have to use the <uses-permissions> in the AndroidManifest.xml e.g. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION">

So now I want to control this permission programmatically. Can it be done? If Yes please share some pointers.

Thanks, Punit


You can't do that.

But what you can do is create a boolean variable in SharedPreferences and then check that in your service / activity.

So now I want to control this permission programmatically. Can it be done?

No, sorry. You have to ask for that permission in the manifest, and the user has to grant that permission at install time.

Yes it can be done only if phone is rooted though! There are apps on Google Play Store to do just that. And here is an open source project that does it to: https://groups.google.com/forum/?fromgroups#!topic/android-developers/aouN769ewOU

Need Your Help

Hide command arguments in PHP exec()

php linux hide exec

I have a script, written in C, which requires 3 parameters: host, name, password, like this:

PHP Background Process Still Affecting Page Load


So I have found a number of tutorials/guides for running a php script as a background process, but no matter which code I use, the process still appears visible in the browser.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.