• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Install apk by code

cmasmas

Newbie
Hi,

I am developing an applications that depends on other. How can I check if that application is already installed, and if not, "call" the Market so the user can install it?

Another question: is it possible to install an APK from code? If so, how?

Thank you very much
 
Um, have you tried searching for this? I'm sorry to be this rude, but there are a ton of answers coming up for your subject line.

Here are a few good starting points:

  • Android Developer's Reference: PackageManager is the foundation of what you want to do
  • Android Snippet: listPackages can be modified to look for something specific
  • According to a Google Groups thread, you can "pass your Intent to PackageManager's queryIntentOptions() method. If you get back an empty list, [the app] will not be available (more accurately, nothing will be able to handle your Intent)".
Also, you can fire off a "market://com.example.yourmissingapp" to start the installation process for the user. However, the user must still manually go through the installation procedure (that's a feature, not a bug).

Good luck!
 
Hi!

First of all, thank you very much for your answer. I just didn't know how to search for it.

However, the user must still manually go through the installation procedure (that's a feature, not a bug).

The Android application should connect to a service and download an apk. So, is it impossible to install it directly, without using Market?
The application is for blind people, so the point is to be able to install it directly. Or at least, launch the installation of the apk.
I would appreciate any help.
 
If you take a look at Titanium Backup, you'll see that it requires some background library (unix tools, really) and that it's able to detect its absence and automatically download it. The only reason it can only do this is because Titanium Backup requires root access.

For normal APK's, you can launch the Market in such a way that it shows you the app's page, and I think you can even start the process (what amounts to the first press on the "Install" button), but you do have to go through the subsequent screens (granting rights, install ok, etc.) manually. Even the rooted Titanium Backup, when using it to do a batch restore of apps, has to take you through all these screens for each app while it's restoring.

So you see, you can't really do that. :(
And I hope you understand how that's a security feature. :o

*Disclaimer: I have no affiliation with Titanium Backup beyond being a satisfied user; it's just a pertinent example of a root app working with APK's.
 
Back
Top Bottom