Johny19 Johny19 - 1 year ago 379
Android Question

No Activity found to handle Intent when using FileProvider

In my app I have a custom auto download and install APK it works like this

// auto register for the complete download
activity.registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

// Download the file through DownloadManager
String destination = Environment.getExternalStorageDirectory() + "/";
String fileName = "myfile.apk";
destination += fileName;
final Uri uri = Uri.parse("file://" + destination);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(apkUrl));
final DownloadManager manager = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
final long downloadId = manager.enqueue(request);

onComplete = new BroadcastReceiver() {
public void onReceive(Context ctxt, Intent intent) {

Intent install = new Intent(Intent.ACTION_VIEW);
// BEFORE working doing this
// manager.getMimeTypeForDownloadedFile(downloadId));

// Using file provider it doesnt work
Uri apkUri = FileProvider.getUriForFile(AutoUpdate.this,
"com.myapp", file);


Android manifest:


Provider_path (Sorry for some reason so cuts the path tag)

external-path name="myfolder" path="."/>

When the file finished to download the onComplete is called but the activiy doesn't start:

No Activity found to handle Intent { act=android.intent.action.VIEW
typ=application/ flg=0x4000000 }

When using the normal file:// it does work

Is there something I'm missing when using the file provider? Does the activity doesn't start because the file is not found ?
Do I need extra permission ? (at the moment I have INTERNET, READ and WRITE on external storage)

Answer Source

The package installer only supports content schemes starting on Android 7.0. Prior to that — and despite documentation to the contrary — the package installer only supports file schemes.

You will need to set the Uri on your Intent differently based on whether you are running on Android 7.0+ or not, such as by branching on Build.VERSION.SDK_INT.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download