-1

i tried to download apk file using intent

 Intent intent = new Intent(Intent.ACTION_VIEW);           
 intent.setDataAndType(uri,"application/vnd.android.package-archive");
 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);     
 startActivity(intent);

i got an exception

 02-05 16:48:35.207: E/AndroidRuntime(2719): FATAL EXCEPTION: main
02-05 16:48:35.207: E/AndroidRuntime(2719): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://192.168.102.157:8080/ApkDownload/Download typ=application/vnd.android.package-archive }
02-05 16:48:35.207: E/AndroidRuntime(2719):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
02-05 16:48:35.207: E/AndroidRuntime(2719):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
Mr.Me
  • 9,192
  • 5
  • 39
  • 51
Bucks
  • 689
  • 3
  • 11
  • 28

2 Answers2

0

The system installer can only open APK files present on the Local file system. You can download the APK yourself and then install it, or you can use the same intent without the mime type to download it using the default browser (then the user will have to click on the downloaded file to install it).

XGouchet
  • 10,002
  • 10
  • 48
  • 83
  • i dont want to install the App. i need to just download the Application and store it somewhere else or store it in download folder in sdcard – Bucks Feb 05 '13 at 11:34
  • Then just use the following line to download it :intent.setData(uri); – XGouchet Feb 05 '13 at 12:52
0

Ok, The exception you are getting ActivityNotFoundException is because your android emulator doesn't have Google Play installed on it.

You should not have any problem testing it on any actual device.

For more info about Google Play On Emulator please visit this link Google Play On Emulator

Community
  • 1
  • 1
Mr.Me
  • 9,192
  • 5
  • 39
  • 51