[android-developers] How to programatically install an app (apk)

2013-03-07 Thread JavaSrvcs
I am looking for two examples (have searched all over, found many examples 
and nothing works).

Inside an activity, I want to be able to install an app 
From the Google Play Store
From a url:  http://host/path_to/app.apk

I tried this:

apkurl is defined above as private String apkurl = 
http://host/path_to/app.apk;;

this following method called from onCreate()
...
private void installApp() {
try {
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse(apkurl))
.setType(application/vnd.android.package-archive);
startActivity(promptInstall);
} catch (Exception e) {
e.printStackTrace();
}

When the above code is run, I get this exception in the debugger
// android.content.ActivityNotFoundException: No Activity found to 
handle Intent { act=android.intent.action.VIEW 
typ=application/vnd.android.package-arc
}

I am also looking for a way to install an app via the market URI, I have 
tried half a dozen examples and nothing works.  If there is an Intent that 
I can run that will install an apk from the market for from a direct url 
link to an apk, please advise.  Spinning my wheels here to get this to work 
and any help would be appreciated.

thanks

J.V.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] How to programatically install an app (apk)

2013-03-07 Thread Mark Murphy
On Thu, Mar 7, 2013 at 5:52 PM, JavaSrvcs jvsr...@gmail.com wrote:
 Inside an activity, I want to be able to install an app
 From the Google Play Store
 From a url:  http://host/path_to/app.apk

These are mutually exclusive. One URL can *either* point to the Play
Store *or* point to your own Web site, not both.

Moreover, there is no way to point to the Play Store to trigger an
immediate download AFAIK.

 When the above code is run, I get this exception in the debugger
 // android.content.ActivityNotFoundException: No Activity found to
 handle Intent { act=android.intent.action.VIEW
 typ=application/vnd.android.package-arc

That's because you did not download the APK file. The installer will
not handle http: Uri values. You need to download the APK yourself to
external storage, then trigger an install of the downloaded APK.

 I am also looking for a way to install an app via the market URI, I have
 tried half a dozen examples and nothing works.

That's not supposed to work. You can lead the user to the Play Store
page for an app, but you cannot force the user to download it.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.6 Available!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.