Install apk by code


Last Updated:

  1. cmasmas

    cmasmas Member This Topic's Starter

    Joined:
    Mar 13, 2010
    Messages:
    15
    Likes Received:
    1
    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
     

    Advertisement
  2. cmasmas

    cmasmas Member This Topic's Starter

    Joined:
    Mar 13, 2010
    Messages:
    15
    Likes Received:
    1
    Any tips? I don't know how to look for information :S
     
  3. KlaymenDK

    KlaymenDK Well-Known Member

    Joined:
    May 29, 2009
    Messages:
    1,217
    Likes Received:
    130
    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!
     
    Zilon and cmasmas like this.
  4. cmasmas

    cmasmas Member This Topic's Starter

    Joined:
    Mar 13, 2010
    Messages:
    15
    Likes Received:
    1
    Hi!

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

    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.
     
  5. KlaymenDK

    KlaymenDK Well-Known Member

    Joined:
    May 29, 2009
    Messages:
    1,217
    Likes Received:
    130
    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. :eek:

    *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.
     
  6. cmasmas

    cmasmas Member This Topic's Starter

    Joined:
    Mar 13, 2010
    Messages:
    15
    Likes Received:
    1
    Thanks again! I'll try using Market then.
     
  7. king angels

    king angels New Member

    Joined:
    Jun 11, 2010
    Messages:
    3
    Likes Received:
    0
    Check with th local buiding code director in your area. It varies by area.
     

Share This Page

Loading...