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);
精彩评论