how to automatically install an apk - android

Is there a way to automatically trigger the installation process of a just downloaded apk ?
Currently after I download the package , nothing happens unless I click the package ,in which case the packege installer is launched !
The tomcat server from where I download the package has in the web.xml file the following :
<mime-mapping>
<extension>apk</extension>
<mime-type>application/vnd.android.package-archive</mime-type>
</mime-mapping>

That is exactly as it should be. Your app can trigger download of an apk but to install it the user must be shown the permissions it requests and explicitly agree. You absolutely cannot 'automatically trigger the installation process'. Even if you are updating an already-installed app.

OS-level permissions are required to call the PackageManager APIs that actually install APK files. These are not available to developers or 3rd party apps.
Since the Android Marketplace is part of the OS and has OS-level permissions, it can prompt the user for permission to download and install an app once before the download begins, and continue the rest of installation without user input.
3rd party apps cannot do this. By design, the only method available for developers/apps to install APK files is to launch the PackageInstaller activity, which will always require an extra verification step from the user before the install happens.

Related

Android INSTALL_PACKAGES Permission and Non-PlayStore Apps

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.

Android market application autoupdate

Some of the applications I have installed on my phone update automatically, I don't even have to click anything. This is the behavior I expect from the application I'm developing myself. Do I have to configure something or will android market take care of this?
This is not a behaviour you can set on the application itself. Each user chooses how the applications he downloads are updated. This is a market setting.
In the latest versions of the market, the default is now set to auto-update, but the user is free to untick the box and decide for manual updates, per application. If you open settings, you can also decide whether it's done on Wi-Fi only or on mobile data as well.
This will be done on all updates except the ones where a permission change occurred. For them, the market will still require a manual update.
Auto update is possible. But you should click app to start it at least.
In the start process, you can send the current version status to server through web service, server will identify the version if there is new version. if yes, a new version apk file will be downloaded, and the most important is how to install a apk file sliently.
Generally, you can run the
pm install -r xxx.apk
the apk will be automatically installed, and your app will be updated.
I'm almost positive you can't force users to update their installed apps, but I think it is the default behaviour of the Android Market.

How to automatically launch the Android installer after downloading the apk?

When you install an app from Google Market, you have an install button, which downloads and automatically starts the installation program for the apk you just downloaded. It doesn't install it automatically, only it automatically launches the installer for the apk you just downloaded.
Is it possible to have a similar button if you have a apk file on your local server? How will the link look like?
I've read a lot of almost similar questions here (like this one
How to install APK automatically when the file download is complete (hosted on private) or how to automatically install an apk), but none of the answers explained if Google uses something special for its market or is it possible to use a special kind of a link to force the installation program from the phone to automatically launch after download? Automatically LAUNCH, not automatically INSTALL the apk.
That is, when users scans my QR code with a QR code reader or types directly the URL in the browser, how can my application trigger the installer program right after download?
Let's say I do the following:
1. I generate a private key on my computer
2. I sign my app with my private key
3. I submit my app to Google market
4. I upload my app to my site.
When someone will download my app from Google Market, the following will happen:
a) That person will access the Google Market URL of my app
b) He will download it to his phone
c) The application installer from the phone will start automatically, and ask him if he agrees with the permission required by the app.
When someone will download my app from my site, the following will happen:
a) That person will access the Google Market URL of my app
b) He will download it to his phone
c) The application installer from the phone will NOT start automatically.
I don't want the app to install without any intervention from the user, just for the install process to start automatically after download.
My question is how to make c) to happen even if he downloads the same app, signed with the same signature, but from my site?
The simple answer is: You can't (at least if I'm remembering correctly).
AOSP contains a set of Google's public keys that they sign their applications with. And in order to be able to install an application without any intervention from the user, the apk must be signed with the matching private key. So, in order to do this, you will have to do one of two things:
Get google's private key and sign your apk with it.
Get everyone to upgrade their phone to have your public keys along side google's.
Neither of these are really possible. So basically, you can't. Unless your targeting the root/rom community. Then you might be able to convince them to do #2 (add you to the list of keys that can install apps without intervention).

Install apk file via code forcibly

I have a scenario where I have to install an apk file through code and I dont want the user to have option either install or cancel it. For ex, I want to create an app similar to the android market. In that app, I will display list of my applications and display an install button for each app. When the user clicks the install button, the app should be installed directly without asking the user to install or not. I found a link which have a method installPackage in PackageManager. I am getting compilation error when I use it. It seems that it is remove from the android framework.
Is there nay possibility to do this ?
thanks,
Senthil

How to install multiple apks at a time?

Am developing one Android application which is using thinkfreeoffice.apk for viewing documents in my application. My requirement is I have to download both my application and thinkfreeoffice apks at a time and also install both these apks at a time.
anybody did this one before?
You cannot literally, unless your application is signed with the system certificate or you are using the SDK/ADB install method from a connected PC, or you find and abuse some security bug. As a security measure, any installation done by a normal application on the phone will require the user to go through the confirmation dialog one app at a time.
What you can do is put check in your application for the one it depends on, and keep complaining/downloading/ACTION_VIEWing the downloaded package upon startup of your app until the user either decides they don't want to use your app or agrees with the system install dialogue for the app you depend on.
I think it's impossible to install multiple applications at the same time, as the user has to confirm installation for each apk.
You could of course make the user install your application first, then ask the user to install the office application after which you use an intent to start the installation or redirect them to the Market.
Similar implementations have been used in applications that use third party barcode scanning or speech recognition.

Categories

Resources