Always Allow Background Location Android 11 - java

I'm currently working on an app that requires users to have background location turned on as it is a core element.
Currently the app requests location and functions properly, but the user must manually go into settings to change to allow always. However, our users are generally not technically-savvy individuals, so I would like to make it so they can click allow always right when prompted for location.
I have been researching this topic for a few hours now and I cannot find a simple solution that doesn't require use of a library. According to Google's documentation, https://developer.android.com/training/location/permissions#request-background-location, this should be simple using the function getBackgroundPermissionOptionLabel(). I am unsure of the context to use this, and searching the function itself has not yielded any results.
I have also found their sample project,https://github.com/android/location-samples/tree/master, which includes LocationUpdatesPendingIntent that prompts the user for permissions but only shows a link to go to the location permissions settings page.
Currently here is exactly what we use for requesting the location permission, which is identical to what the example uses.
ActivityCompat.requestPermissions(MainActivity.this,
new String[] {
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_BACKGROUND_LOCATION
},
REQUEST_PERMISSIONS_REQUEST_CODE);

Related

how to remove the third permission option

I've already googled this question but haven't found anything yet, so I need your help. How to remove the third option of permission to the memory, because if the user accidentally clicks on it, it will be necessary to go to the settings and allow the permission to the program manually, and since in general 30-40% of users are able to do this, only one will have to reinstall the program .
As people in the comments have said, it is a system dialog and you cannot change it. If you want to help users find your app's settings you can try sending them there.
Also note that according to the docs
Starting in Android 11 (API level 30), if the user taps Deny for a specific permission more than once during your app's lifetime of installation on a device, the user doesn't see the system permissions dialog if your app requests that permission again. The user's action implies "don't ask again."
So you have to deal with permanent denials even if there isn't a dedicated button.

How to get current Location when app is minimized

I'm working on a sports application where I have to constantly get accurate live location from user and send it to the server, even when the application is minimized. The official android developer page says background location access is only possible when a user selects 'Allow all the time' on a settings page.
Android Developers > Docs > Guides > Request background location
This, I find, is programmatically impossible. At the same time, there are multiple apps (Strava , Map runner, runkeeper) which are able to get GPS coordinates when the app is minimized without getting the permission.
If anyone happened to dabble in this sort of thing, I would like to have your inputs. Thank you.

App crashes when depricated PERMISSION not used (KITKAT) [duplicate]

I have an security App (App Locker) that uses this permission:
android.permission.GET_TASKS
In android Lollipop this permission is deprecated and i want that my app works in +21 API.
Can anyone guide me how?
Thnx :)
There is reason why it is deprecated.
The protection Level of android.permission.GET_TASKS has been elevated to signatureOrSystem.
There is no easy and unharmful solution for that.
As of LOLLIPOP, this method is no longer available to third party applications: the introduction of document-centric recents means it can leak personal information to the caller. For backwards compatibility, it will still return a small subset of its data: at least the caller's own tasks (though see getAppTasks() for the correct supported way to retrieve that information), and possibly some other tasks such as home that are known to not be sensitive.
http://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks(int,%20int)
I saw a new permission REAL_GET_TASKS that is said to be used instead of GET_TASKS:
New version of GET_TASKS that apps can request, since GET_TASKS doesn't really give access to task information. We need this new one because there are many existing apps that use add libraries and such that have validation code to ensure the app has requested the GET_TASKS permission by seeing if it has been granted the permission... if it hasn't, it kills the app
with a message about being upset. So we need to have it continue to look like the app is getting that permission, even though it will never be checked, and new privileged apps can now request this one for real access.
See the Android code difference at: https://android.googlesource.com/platform/frameworks/base/+/2d7576b%5E!/

Modifying installed apps permissions (Android)

I want to develop an application for android to:
List installed applications in the phone.
Show a list of permissions that are granted for each app.
Have the ability to disable any permission granted to a specific app or enable it later on.
Till now I have done the first two points. I searched the web to know how to modify permissions but I couldn't find anything useful.
So can anybody give me a clue on how to implement this ? Because I think it is doable since there some apps that can modify permissions (e.g. Permission Manager).
There are various apps in the Play Store that call themselves Permission Manager so I'm not sure which one you have looked at.
At least one of them works by pulling the installed app apart, and reforming it with a changed AndroidManifest file (and since they don't have access to the original private key, a new signature). To run the reformed app you have to uninstall the old one, and install the new one, which has 2 significant downsides
all the data of the old app is lost
since you now have an effective pirate version of the app, the app will no longer update with new versions from the Play Store.
Other apps that claim to manage app permissions simply expose the hidden App Ops permission screen in Android 4.3, and Google removed this from the later Android 4.4 update.

Android Project - Required Tools

I'm in the process of starting a new Android project that will:
Display a Google map
Track and record users movements
Display the route on the map
Show local points on interest on the map
My question is what extra tools will I need to accomplish this? I can already get a basic Google Map working with zoom controls and place overlays etc. but my main concern is how I will track the users movements. I was thinking there maybe some sort of fleet management API but I really have no idea.
A link to some sort of tutorial would be great or even just to possible tools.
Use the class http://developer.android.com/reference/android/location/LocationManager.html to obtain the device geographical location
A Caltrans planning grant went towards creating an Android app called CycleTracks that does all of your bulleted items except the last one about points of interest.
You can download the source code here: http://www.sfcta.org/downloads/cycletracks/CycleTracks-android.zip
I haven't looked at the license to see how free you are to use it as a starting point, but I have to imagine it might be helpful just to be able to look at it even if the license is restrictive.
You can read more about it at http://www.sfcta.org/content/view/666/375.
You don't need any extra tools. Use the GPS or radio cells to get the location of the phone. This thread explains how you can get the location:
How do I get the current GPS location programmatically in Android?
If you want to Track the users movement you'll need to run a webservice on a server and have the app report the location of a user at regular intervals.
Be careful though, if you don't tell the user this is what you are doing, and provide an opt out, you could be pulled from the market pretty quickly.
Be sure you aren't recording any sensitive information as well. Usually position, phone type and OS type is allowed but much more could get you in trouble.

Categories