开发者

automatic install of apk

I'd like to know if it is possible to trigger programmatically the installatio开发者_如何学JAVAn of an apk that is on the card ?


Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
startActivity(intent);

(courtesy of anddev.org)


Just in case somebody is looking for this info.... If you want to install an apk which you also programmatically downloaded and stored in your private "files" folder (ie. "/data/data/com.yourapp.name/files"), you need to get the uri for the full path by first using getFileStreamPath as follows:

File fullPath = getFileStreamPath("name_of_downloaded_app.apk");

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(fullPath), "application/vnd.android.package-archive");
startActivity(intent);

Hope this helps...


See if this can help: install Apk via Intent. Not sure if this is the way to go though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜