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.
Related
I wanted to use a 3rd-party app with an intent but application is not installed on user's device. Something like Android Instant Run but apk are included in application or If it isn't possible, How can I install apk on user's? However can I install application silently without Package Installer?
I'll be appreciated if anybody answer my questions.
I wanted to use a 3rd-party app with an intent but application is not installed on user's device.
Ask the user to install it.
Something like Android Instant Run but apk are included in application
Nothing like that exists, sorry.
However can I install application silently without Package Installer?
Fortunately, that is not possible, for security reasons.
I have a regular Android application which I am planning to deploy on the Google Play Store.
This application needs a custom application service (no UI) to work as expected. [It is not possible to combine them together].
To improve the User Experience, I would like to make sure that the installation of this application service is invisible to the user. Essentially, I would like to install & update this App2 silently in the background.
What would be the best way to do this?
Thanks.
Your best bet is to just prompt the user to voluntarily install it. You could even make a prompt, let the user know that your app will not function if this other apk is not installed, and give them the choice to install it.
As stated before, there is absolutely no way to install an app without showing the user the full permissions list of the app before installation. This is a strict rule enforced by Google, for good reason. Imagine the security risk of allowing any app to silently install another app!
Here is a simple example of something you could do:
PackageManager pm = context.getPackageManager();
try{
pm.getPackageInfo("com.theappyouneed.example", PackageManager.GET_ACTIVITIES);
//If you get here, the app is installed, nothing to do.
Log.i("MyApp", "package already installed! Awesome!"
}
catch (NameNotFoundException e){
//App is not installed, launch Google Play Store
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.theappyouneed.example"));
startActivity(intent);
}
Documentation on linking to products: http://developer.android.com/distribute/tools/promote/linking.html
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.
I want to build an app able to install apps in any Android Device from my PC, I know about adb terminal application..and I could build some kind of an interface for it, but I have been trying to find any api release that allows me to do the same thing without calling to adb.exe. I dont care if is in java or any other language...anyone knows?
You are welcome to start an activity using an ACTION_VIEW or ACTION_INSTALL_PACKAGE Intent, pointing to the APK file.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive");
startActivity(intent);
I do not think that an api exists. ADB is a client-server program that includes three components: a client, a server and a daemon, so (I think) it's not too easy to create an api. You must take into account that the ADB is the best option, and maybe you can develop a frontend (Eg: http://forum.xda-developers.com/showthread.php?t=970348 )
But if you are just trying to install xpi:
WHy don't you upload your app to Google Play or alternatives?
Also you can copy the app to your phone and install it via Install File Manager or (you need to install it first)
Try something similar to http://www.apkinstall.com/
I think you are trying to install an apk from your apk which is not feasible.
You can listen to other app in your app by broadcasting in other app and receiving that broadcast in your app .
What is the best way to prevent a user from downloading and installing applications which uses some specific permissions like location and sms.
Is it programatically possible to parse the manifest of an application from the market before it get installed and look for the specific permissions and alert the user?
What is the best way to prevent a user from downloading and installing applications which uses some specific permissions like location and sms.
Write your own firmware, where you replace the normal installer mechanism with one that enforces your desired criteria.
Android SDK applications cannot interfere with application installation.
Is it programatically possible to parse the manifest of an application from the market before it get installed and look for the specific permissions and alert the user?
No, sorry.
However, you can listen for ACTION_PACKAGE_ADDED and examine the newly-installed package via PackageManager, and alert the user at that point. Since nothing of the installed package can run immediately upon the install, I would think that there is a decent chance that your alert will appear before the user tries to use the newly-installed app.
In the future this would be probably something you could do trough Device Administration, but right now limiting application installation based on its requested permission is not included.
One option is this snippet that decompress the apk and extracts the AndroidManifest.xml.
By the way the aapt tool for android runs on the Android OS too. You can get this information using this port