installing an app with administrative privilege in android - android

We can install an app with administrative privilege in android. This is very much possible. When the app is installed an activity appears showing up "If we want to activate the administrative privilege?"
But my doubt here is, I want the app to be installed with administrative privileges without user explicitly clicking on Activate(which appears when app is installed).
Actually in my app, there is no activity and the main class is extending application. With in the onCreate() of it, I gave necessary code for installing it as administrative privilege app. The app is getting installed and its even getting listed in the
select device administrators (Settings->Location & Security-> Select device administrators)
But, it is not checked by default after the install. Can I check that by default during the install.
Hope I was clear enough. Thanks in advance. :)

Can I check that by default during the install.
No, sorry.
I want the app to be installed with administrative privileges without user explicitly clicking on Activate(which appears when app is installed).
That would be a massive security hole.

Related

Prevent Android App from getting installed on multiple users

When I run my app from Android Studio and install it on the primary user on a device, I notice that it gets installed on the secondary user as well.
In the first place, why is this happening? The android:requiredForAllUsers flag is false by default, and in any case can only be used by system apps or pre-installed apps.
Or is it the case that this happens only for debug-mode apps installed via Android Studio?
How can I prevent this from happening?
It is critical for my app that it be installed on one user only. I have already read the following documents:
Supporting Multiple Users
Manage multiple users
Neither of those documents has any explanation of whether and how the installation process is affected by the multi-user feature.
There must surely be some manifest or build setting that permits or prevents installation on multiple users. Why isn't it easier to find? And why isn't this question more common on SO?
You don't prevent it, you do what you need to do: in this case it would be defining your run configuration so the app gets only installed where you want, because per default it gets installed everywhere I suppose. You can do this by specifying the flag --user user_id. You can get the id with adb shell pm list users
Reference: Android Studio 2.3.2 Launching the app under a work profile or another user account on the target device will result in a crash
The easiest way is to add the --user current flag to launch configs.
Select Launch Configurations
The under Install Flags, add the flag --user current. This will ensure the app is only installed on the current user and not on any guest acconuts.
For Android Studio 4.2
GoTo Run > Edit Configurations then Check the Install for all users(For both personal and work profile) and uncheck only for personal profile

Android Device Admin app enabled by default

I have a question about admin apps on Android that I can't find the answer to. I followed the guide on creating an admin app from here:
https://developer.android.com/guide/topics/admin/device-admin#java
I successfully created an admin app but there's something that's confusing me. I have a fresh device (Moto G6) and when I go into Settings->Security&Location->DeviceAdminApps I see a list of admin apps on the device. Right now it lists my app and a Google Play Services app titled "Find My Device". The only difference, though, is that the google app was on by default. Normally, and including in my app, when I try to use an admin feature (through DevicePolicyManager), an android page pops up asking me to enable it as an admin app. Since the Google app is already enabled, that pop up doesn't need to appear.
So, my question is how do I make an app an admin app by default (without needing the pop up page)? I assume something needs to be done on boot up but I have no idea what that Google app does. Does anyone out there have any idea?
So, my question is how do I make an app an admin app by default (without needing the pop up page)?
Build your own firmware with your own custom build of Android, where you pre-install your device admin app and set things up for it to be pre-enabled.
Alternatively, I think if you create a device owner app, it will be enabled upon installation, but that installation happens when the device is being first set up.
Ordinary device admin apps require users to agree to enable them, for blindingly obvious security reasons.

How to uninstall app which is set by password?

I developed one parent and child communication Android application in which I wanted to restrict the child from uninstalling application. I have one solution that uses DevicePolicyManager. But still the application can be uninstalled without asking for password. If I remove the Device Administrator permission from the settings, then application is uninstalled from device?
Can anyone provide the valid solution for this cause?
You cannot prevent a user from uninstalling an app, from within the app code itself.
There is suggestions here How to prevent an application from being uninstalled?, but they are not foolproof.
The way around this is to use an android device with lollipop and upwards, so you can create a user account.
On the admin account, install an app that requires a password to uninstall apps. They are on the market (and free) I've used them. Or write one yourself.
Then on the child's account allow them whatever privileges you want them to have. They will be unable to touch the apps and uninstall them, unless on the admin account and with the password required for that app to uninstall other apps.
I have tried and tested this and it works.

Android permissions not requested after reinstall

I am testing my Android app on my own phone. When I first run it on my phone, it asks for permission to user my gmail account. When I reinstall my app, it no longer does that? I would like to make it so that it re-requests permission every time I reinstall the app for testing purposes. If, on the other hand, I change the package name, it re-requests the permission. Does anyone know how to do that? Much help would be appreciated!
Thanks!
Note: By reinstall, I mean both pressing the run button and actually resinstalling the application by first uninstalling via settings.
This is not an actual Android permission, it's actually an account access grant specific to AccountManager. Technically, when you uninstall an app all grants should be cleared, but this appears broken on some devices. If you have a rooted device or are using the emulator, you can find accounts.db (usually in /data/system/users/0/accounts.db on newer versions) and clear the grants and extras tables (that could affect other apps, so handle with care). If you don't, clearing the data for Google Account Manager and Google Play Services could help.
What do you mean by reinstall? Does reinstall simply meaning pressing the "run" button? Or are you actually uninstalling and reinstalling the application. Once the Android OS detects that a permission is needed, it will request it from the user. But after that first time, it won't ask again. If you completely uninstall the application from the device and then reinstall, it should work. I don't know of any other way you can bypass that.

Password Protected at Un installation time

I am trying make security app for keeping tracking your lost phone.I made app as device admin app so it can't uninstall directly but using unregister app to device admin we can un- installed it.so i wants make password protected app at un-installation time.when user try to un-install the app one dialog box appear to ask password.i know some apps do that functionality.can anyone knows about it?
You can't do this on a stock device. If you want to prevent people from uninstalling your app you have to make it a system app (part of the ROM). Even so, on recent Android versions users can choose to disable it. On Android 4.3 you have the option of marking the device admin (system app) as a 'device owner' so that users cannot deactivate it. This is obviously not available on earlier versions.

Categories

Resources