I am playing around with the BasicManagedProfile sample and want to install a custom app to only the managed profile. I can easily go to the play store, download, and install an app and it will only appear in the apps of the work profile.
However, using the standard Intent way to install an apk from the device does not seem to work.
final Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setDataAndType(Uri.fromFile(new File(APK_LOC)), "application/vnd.android.package-archive");
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, getPackageName());
startActivityForResult(intent, REQUEST_INSTALL, null);
Like normal, if the "Install from unknown sources" security setting isn't enabled, a dialog will pop up that sends you to the Settings app to enable it. However, in a managed profile app, this dialog always pops up regardless of whether or not that security setting is checked. It seems the settings are not reflected in a managed profile (which makes sense because it's an entirely separate settings database).
I have tried opening the Settings app directly, but it's still the same. It just goes to the standards Settings app and not a Managed Profile settings app.
Is there a way to change this security setting for a managed profile or install an app from the profile owner app? Since my app is the profile owner it seems this should be allowed. It's easily possible for system applications, but third party apps will not work with the DevicePolicyManager#enableSystemApp() method.
EDIT:
I have also tried installing from a Manage Profile Gmail app. Same thing. It does not seem possible to install apps outside the Google Play store in a managed profile.
Google has restricted the direct installation of .apk files in the managed profile.
The unusual behavior of the alert box saying the user to go to settings and enable the "install from unknown sources" even though it is enable is considered as an issue. See the Google issues page here .
Is there a way to change this security setting for a managed profile
or install an app from the profile owner app?
Currently there is no API or work arounds to install an .apk file in the managed profile. But for testing you can try through adb
adb install appname.apk
This command would install the application in both the personal and the managed profile. Hope this helps you!
Go to edit the configuration in Android Studio as shown below in the image and then click check Install for all users to install app for Work Profile and Normal Admin similarly uncheck for Normal install.
Related
As we know when we are installing app like WhatsApp , Facebook etc. from play store then it automatically listed in a list of autostart application on boot.
As shown in below screenshot we can see how these application are listed in autostart application which automatically turned on after installing.
So my question is how can I list my app in the auto-launch apps list. After installing my app, its showing in list but its not enabled. But I want that after installing it should automatically enable.
I know there is a way to achieve this. Please help I didn't found any articles about this.
From my understanding, this can't be achieved by every app. The apps you see, which are automatically auto-launching after installation are white-listed by manufacturers or Google themselves. All you can do is send the user to the specific settings to enable the auto-launch after installing the app. This is also described here:
Add my app to AutoStart apps list in android programmatically
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.
I've and application that requires a secondary application to be installed to work . Reason for this vary, mostly memory (both flash and ram) footprint if this is used from multiple applications.
Anyway, it's not very convinient that a user has to go to the playstore again after having downloaded and started the first app.
Now I've discovered google drive does the same with google docs/sheets/presentation. You first install google drive, and when you need another application you still need to install it.
However google drive manages to show an "do you want to install this application" popup immediately instead of just redirecting the user to the playstore: See https://drive.google.com/file/d/0BxHD8LQaDPnrbXpEcm1HdV9KVkpNOUlRWldyVjhBbnFkSFJN and https://drive.google.com/file/d/0BxHD8LQaDPnrRS1PSHdyNDRXT3Nzb3BBVjNfSDVRbDZhaGpN
Question is: does anybody have an idea how to do this? Or is this an api that only google apps are allowed to use? I've not found any documentation about it. Decompiling the google drive app also did not help me much, it's heavily proguarded.
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse(yourApkFilePath),
"application/vnd.android.package-archive");
startActivity(promptInstall);
Download apk file to sdcard(from your server) and use above code with filepath. It opens a prompt to the user whether to install new application.
Note: this works only if the user checks "Install app from external sources" in the Settings
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.
I'm searching for a way to program my application to install silently an APK file.
I'm aware about the possibility to launch with code that looks something like this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
startActivity(intent);
But before the installation starts, this code raises a dialog with the APK's required permissions, and needs user authorization to start the installation.
Is there any way to skip this dialog?
Is there any other way to install an application during runtime from my code, that doesn't require user interaction?
No. And that's a good thing - this would be an (other) open door to malware and unwanted installs. Why do you want to do that, if you mind me asking? What's wrong with letting users know that you want to install something on their device?
Also, some details here: Silent installation on Android devices
And finally, this might be possible for rooted devices: if you write your own installer, you can bypass completely the built-in installer, and with root privilege, you can basically do what you want. But I still think that would be a serious breach of security.
Yes you can, but you need root access or your app must be a system signed app.
You can install apps silently by using shell commmand pm install "apk path".
This will definitely work - I have already created a sample app that does this.