开发者

How can I show file in sdcard to user?

开发者_如何学PythonI want to show user my apk file using intents, here is the code:

 SDCardRoot = Environment.getExternalStorageDirectory();
 File file = new File(SDCardRoot,fileName);
 if (file.exists()) {

Uri path = Uri.fromFile(file);
Intent intent = new    
Intent(Intent.ACTION_VIEW,path);                                
startActivity(intent);

but it is giving me ActivityNotFoundException,I want to start the apk file so that user can install it.


Try this?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜