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
Related
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.
Today the Google Drive app asked if I wanted to install the new apps Sheets & Docs.
I've accepted, expecting it to open Google Play Store so I could press install.
It didn't. It just showed me the popup with the permissions of each of the apps to confirm the installation, the same that appears when you press "Install" on any app on the Play Store.
I was not aware this could be done.
How can we reproduce this behavior in an app: have a button "Install App XPTO" which doesn't need to open Google Play Store? Just shows the permissions dialog and proceeds to install it via Play Store?
UPDATE:
For those downvoting because they think this is the same as other questions... It's not!
In this case, the APK is not downloaded by Google Drive app and then installed. Google Drive "tells" Play Store to download & install.
That's the API that I'm interested.
To support my case: after pressing INSIDE Google Drive to install the apps without opening Play Store, the download starts. During the download I've opened the Play Store to check and:
The screenshot proves that it isn't Google Drive downloading the APK and the installing it. It's the Play Store.
The logs for Google Drive shows that activity responsible for "telling" the Google Play Store to install apps is
com.google.android.apps.docs/com.google.android.apps.docs.app.PhoneskyApplicationInstallerActivity
which, apparently, "tells"
com.android.vending/com.google.android.finsky.billing.lightpurchase.LightPurchaseFlowActivity
to install required packages.
So, theoretically, one could create an intent
Intent intent = new Intent("com.android.vending.billing.PURCHASE");
intent.setClassName("com.android.vending",
"com.google.android.finsky.billing.lightpurchase.LightPurchaseFlowActivity");
intent.putExtra(EXTRA_NAME, EXTRA_VALUE);
startActivityForResult(intent, 0);
with correct extra values and voilĂ !
However, calling LightPurchaseFlowActivity from non-Google signed app is failing, because they are, again apparently (according to the logs), checking the calling package's signature:
W/Finsky(13209): [1] LightPurchaseFlowActivity.setupFromExternalPurchaseIntent: Called from untrusted package.
So, there, this can not be achieved at this moment.
Google+ now implements buttons where you can directly download an app (see this link) without clicking the button on the play store site.
The link looks like this:
https://play.google.com/store/apps/details?id=com.example.app&rdid=com.example.app&rdot=1&feature=md
If you add the rdid, rdot and feature parameter it works on my phone (if I type it in the browser, not tested with an intent and not tested to update an app, only installing it).
Edit:
I found out that you only need to add the rdid-parameter to the url. Source: http://www.androidb.com/2014/04/increase-app-installs-with-a-single-trick/
Edit2:
Does not work with an intent. :(
I'd say that the Google Drive has system permissions, just like the Play Store. Probably because it is signed with Google's signature.
If you manage to have the "android.permission.INSTALL_PACKAGES" permission you can call the API (which is not included in the android.jar deployed by SDK Manager, you have to get the hidden APIs from the android.jar in the emulator for instance) to install the applications.
So, basically, unless you have system permissions (by putting your APK into /system/app, signed with OEM certificate or with root) you won't be able to do it.
Source: Already programmed some system apps
--- UPDATE
Of course the play store may have some door that you can use to install any application but that probably requires a permissions that you can't get on your own
If you know where you have the apk file, you can easily.
File file = new File(dir, "YourApp.apk");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
I'm preparing my app for the play store and plan to deliver one component as separate install package (since my customer can't recover the source code, but the app is signed with his key). I thought about two ways of doing that. My needs are just these: Users with "unknown sources" deactivated should be able to install the 2nd app. And: The user should never be redirected to Google Play store.
Both apps are free.
I've looked up for solutions that would let me download an additional APK from Google Play and simply present the user an installation screen to acceppt the installation. I would like a solution, where I sent an intent to the PlayStore app and it displayed the app name, permissions and the install button. I've found nothing. Anyone any experience here?
I thought I could package this additional app into the assets of my enclosing app. I'd need to write it to the file system and send the system an intent to install the package. Problem: The App was not loaded from Google play and with that it's source is unknown. If I used the PackageManager and let it install the APK, does the permission INSTALL_PACKAGES allow my app installing this 2nd app on a user's device (since the user already accepted that my app may install packages)?
I hope someone may help. And thank you in advance.
My needs are just these: Users with "unknown sources" deactivated should be able to install the 2nd app. And: The user should never be redirected to Google Play store.
This combination is impossible, barring a major security flaw in Android and/or the Play Store. The only way to install apps through the Play Store is via the Play Store app.
I would like a solution, where I sent an intent to the PlayStore app and it displayed the app name, permissions and the install button.
That activity is not exported. You are welcome to use a market:// Uri to lead the user to the Play Store, where they can review this second app and decide, for themselves, whether or not to download and install it.
since the user already accepted that my app may install packages
Your app cannot install packages directly, unless it is signed with the firmware signing key or is installed on the system partition (e.g., by a rooted device user), as that is the only way that you can hold the INSTALL_PACKAGES permission. Ordinary SDK apps are welcome to create an ACTION_VIEW or ACTION_INSTALL_PACKAGE Intent to request that the app be installed, but the user will need "unknown sources" enabled.
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).
I'm developing an application that will most likely be preinstalled on devices. It will be also available on Google Play. Is there a way to update those instances that are not downloaded through Google Play, since Google Play won't notify users about an update.
I was thinking about, as suggested here, trying to contact my site periodically, and when update is available, download it.
Is there a way to do this update automatically, or even silently, so that user doesn't have to do anything (like running the package manually). Or, when my site shows update is available, to offer users an update through Google Play, even though it's not installed through Market (EDIT: This Google play option would be preferable, because than users wouldn't have to check "allow install of non-Market sources".)
i had the same issue, now i check at the start of my app if theres a new version in my configuration xml.
I compare the actual version with the tag "< app_version >1.1< /app_version >" of my configuration.xml
if its lower i ask with a custom AlertDialog if the user proceed with the upgrade
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse(myapk_link));
startActivity(intent);
after the download the user has to run the package manually.
if you choose the update from the Android market use:
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://details?id=com.package.name"));
startActivity(intent);
com.package.name must be the "package" of your app
or
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://search?q=" + APP_NAME));
startActivity(intent);
Just found a way that works. Fire an Intent for a Market that searches for my application.
Tested with OpenIntent Newsreader because for it was easy to find an older version .apk. Market finds an application, and when user clicks install, replaces older version with the one from the Market. I think that is much easier solution for a user than downloading manually .apk and running it.
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("market://search?q=" + APPLICATION_NAME));
startActivity(intent);
Is there a way to update those instances that are not downloaded through Google Play, since Google Play won't notify users about an update.
Old question, new answer:
After digging on exact the same question (pre-installed app on device, how can I provide a update through Google-Play) I found this information on support.google.com*:
Google Play can manage updates to preloaded applications, provided the following conditions are met:
The preloaded app needs to be in the system partition
The preloaded app needs to be free
The preloaded app needs to be signed with the same signature as the app published in Google Play
The Package Name of the preloaded and updated app needs to be the same
The Version Code of the updated app needs to be greater than that of the preloaded app
* as of 2015-04-13
I'm developing an application that
will most likely be preinstalled on
devices.
Then you need to be talking to the device manufacturers and asking them your questions. Nobody else will be able to tell you what is and is not possible, given their device and the carrier(s) that will distribute it. The answers will depend heavily on how they create their firmware, whether your application will be part of the firmware or "installed" as a normal app, what their arrangement with the carrier is vis a vis firmware updates, etc. You may not even get a vote in the matter.
Here is the option for latest version update
https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness
try this google library to update from the application
dependencies {
implementation 'com.google.android.play:core:1.5.0'
...}
I hope this will help anyone
If whoever bundled the app on the device does a proper job of it, then the app will still have a market link (even as a system app) and Market will prompt the user to upgrade it if a new version is available. After all, that's exactly what happens with an app like GMail that's pre-installed on phones.
You cannot install or upgrade a package automatically. Only the Android Market is capable of doing this (i.e. it silently updates itself).
You can certainly download a package and fire the Intent to install it, but the user will have to have the "Allow non-Market apps" options enabled, and they'll still have to manually approve the install/upgrade.
One place to possibly investigate is how Google Maps does it. This is generally pre-installed, but always appears to be shown as an update in the Android Market app, I believe. Whether there's a special flag in the packages.xml or manifest, I don't know.
There is a nice service that helps your app keep itself updated. Take a look at https://www.pushlink.com
In this product there is a NINJA mode that allows to perform updates without user interaction.
For other "modes", enabling "Install non-market app" is still needed. If it not enabled, the installation process is going to ask for it and redirect the user to the Application Settings, and after that, the user can install the app.
It's possible to fully automatically update an app, if you can sign an app as a system app. We wrote an app for specific hardware, we created an update app that the manufacturer signed for us. The update app runs on device startup, checks current version of the app and the new version, and installs the new version if necessary.
The use case would be a kiosk app, on tablets of one make and model, that don't have Google Play.
Google in 2018 Android dev summit announced android in-app update api's for developers so you can read whole story out here and get updated on this question.Android in-app update api details
https://developer.android.com/guide/app-bundle/in-app-updates