ActivityNotFoundException calling an intent on android

395 views Asked by At

When I try to execute this code I get an ActivityNotFoundException ,I think it's because I'm trying to call an activity which is not in the manifest but i don't know what I have to add to the manifest file.

public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();
    if (id == R.id.action_settings) {
       Uri path=Uri.parse("android.resource://com.android.was4fi/"+R.drawable.miarchivo);
       Intent intent=new Intent(Intent.ACTION_VIEW);
       intent.setDataAndType(path, "application/pdf");
    }
}
1

There are 1 answers

0
Denys Kravchenko On

No, the problem is not in your manifest file. You are trying to use implicit intent and Android system can't find activity that can handle this intent. Read more on http://developer.android.com/guide/components/intents-filters.html#ExampleSend. Also this code should be wrapped in try/catch block.