How to install .apk on multiple phones for testing - android

Hi I am developing a cloud application for android. While developing its a torture to install apk on every phone after a single line change in code. Is there a way to install it through script. or maybe i can put apk to some web/ftp server and from there I can install it somehow on each phone. Atleast I dont have to connect every phone through USB every time.
Please Help

For our production purposes, we use Dropbox on our computers and our devices, copy APKs into it, then click from Dropbox from each of our phones.
edit: When I've had to programatically install APKs in the past, I used something like this (which I can't find where I got it from anymore):
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive");
startActivity(intent);

If you're willing to root some of those devices, you can do adb over wifi (unless they already have that option built-in).
You could also use a web server/gmail (or PushBullet for Jellybean-only devices) to deliver your apk to those devices, but that solution would still require a couple of additional steps from the user.
It's possible to install an application remotely over-the-air to your devices with your own google account without user intervention on the phone itself, but only if it's already published on Google Play. I suppose some of that process could be automated if you take a look at the new Google+ Sign-in api, and/or if you use a selenium script to trigger the installation from your desktop computer's web browser (because user authorization is still required through the web browser on the desktop itself, that's why you'd need Selenium to do that bit).

Related

How MDM install application on device without user interaction?

I am working on one assignment, I need to implement silent apk installation on android phone.I checked many posts and find out that it is possible to install apk only if hone is rooted. But MDM(Mobile Device Management) tools are capable to install apk without user interaction and remotely.Can any body explain me how MDM are capable to do so?
On Android, the MDM companies such as AirWatch must have an os-level app signature for their service app. For example, for Samsung there is this:
https://play.google.com/store/apps/details?id=com.airwatch.admin.samsung&hl=en
Once that service is installed, the OS allows AirWatch to do silent installs because the service is trusted as if it were part of the operating system.
Yes you can install an application silently without user interaction:
To do that your app must be system signed. Secondly you must have the apk of the application you want to install and then you need to run a command pm install which you can do programmatically something like this:
private boolean installApk(String apkPath)
{
Command installEvent = new Command(getCommandList("pm install "
+ apkPath));
return installEvent.executeCommandList();
}
This works for me.

Installing app to managed profile

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.

android google play auto install apk like google drive

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

Is there any API that allows to install an apk in Android?

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 .

Android APK's Silent Installation

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.

Categories

Resources