1. Download our Official Android App: Forums for Android!

Apps Install apk by code

Discussion in 'Android Development' started by cmasmas, Jun 8, 2010.

  1. cmasmas

    cmasmas Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    15
    Joined:
    Mar 13, 2010

    Mar 13, 2010
    15
    1
    16
    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 Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    15
    Joined:
    Mar 13, 2010

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

    KlaymenDK Android Expert
    Rank:
    None
    Points:
    143
    Posts:
    1,217
    Joined:
    May 29, 2009

    May 29, 2009
    1,217
    130
    143
    Denmark
    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 Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    15
    Joined:
    Mar 13, 2010

    Mar 13, 2010
    15
    1
    16
    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 Android Expert
    Rank:
    None
    Points:
    143
    Posts:
    1,217
    Joined:
    May 29, 2009

    May 29, 2009
    1,217
    130
    143
    Denmark
    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 Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    15
    Joined:
    Mar 13, 2010

    Mar 13, 2010
    15
    1
    16
    Thanks again! I'll try using Market then.
     
  7. king angels

    king angels Lurker
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Jun 11, 2010

    Jun 11, 2010
    3
    0
    5
    Check with th local buiding code director in your area. It varies by area.
     

Share This Page

Loading...