2011-04-07 86 views
0

希望有人能幫助我在這,Android說明從應用程序中下載的APK無需通過瀏覽器

我想從一個應用程序,我有內下載的APK,但不通過瀏覽器去通過一個uri。

我可以用視頻文件做它像這樣

Uri uri = Uri.parse(url); 
    //Intent intent=new Intent(Intent.ACTION_VIEW,uri); 
    Intent intent=new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/mp4"); 
    startActivity(intent); 

但不能找到一種方法用.apk文件做到這一點,所以用開始安裝新app.apk。

希望有人能幫助 感謝 露西X

回答

0

你應該能夠爲您所使用的視頻使用相同的技術。但是,您必須指定APK MIME類型(application/vnd.android.package-archive)。

UPDATE

例如:

Intent thingyToInstall=new Intent(Intent.ACTION_VIEW); 

thingyToInstall.setDataAndType(Uri.parse("http://here/is/the/path/to/the.apk"), "application/vnd.android.package-archive"); 
startActivity(thingyToInstall); 
+0

CommonsWare您好,感謝您的信息,你能告訴我怎麼把它與從上述目前存在的一個URL編碼。很多謝謝--------- 我有這個,但想添加MIME類型,因爲你建議 ----------------意圖browserIntent =新的意圖(「android.intent.action.VIEW」,Uri.parse(「http://domain.com/android/direct/apk/app.apk」)); \t startActivity(browserIntent); --------------對不起,它的佈局,但回車鍵將不允許間距...... – Lucy 2011-04-12 10:02:52

+0

感謝CommonsWare,但我收到「SetDataAndType」任何錯誤任何想法什麼可能是錯的,再次感謝..露西 – Lucy 2011-04-12 12:12:28

+0

@盧西:對不起,沒有解析URL到'Uri'。 – CommonsWare 2011-04-12 12:55:47

相關問題