Install apk file via code forcibly - android

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

Related

Need to find out, an application has installed already on the same device?

I need to implement trial period on my application. Once trial period is over,If user tries to uninstall and install the application again, for this case I had write one file on sdcard, if the user re install the application. When they open the application I had shown activation key prompt.
If the user delete the file,they can re install and use the application normally. How to solve this case. Is there any other way to hold the application install details in android device.
Note:
My application is a offline application.It won't need to connect with internet.(So there is no way to register with server).
Take of it this way. Everything you store on your phone will be able to get edited/removed/added. The best approach to this kind of problems is to use a webservice to register a device and check it's register date. However since your application is offline there is no way to do it foolproof.

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).

How to update apk through code

My application is already installed in the devise and i will get notification that you want to update, at one click i want my application get updated programmatically. Is there anyway to do...
Third party developers are not able to install .apk files directly without user intervention.
But you can send request to PackageManager to handle installation of new .apk file. This will show "install the app" dialog to user, and if she accepts the installation, your update will go through.
An example of the described scenario: Android: install .apk programmatically
The only way i'm seeing of doing that, and its NOT a good policy it to have the initial code swapping a specific directory for classes, and if it founds one, load it by reflection on the fly and "replacing" the classe contained in the APK
I don't think this will have a good performance... and should not i repeat NOT be a policy for update.

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.

how to automatically install an apk

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.

Categories

Resources