No action found to work with Intent: android.intent.action.VIEW

This is my code for playing recorded 3gp audio file

Intent intent = new Intent(android.content.Intent.ACTION_VIEW); Uri data = Uri.parse(path); intent.setDataAndType(data, "audio/mp3"); startActivity(intent); 

But when I launch it on my HTC device (Android 2.2 Froyo), an exception appears:

 05-04 16:37:37.597: WARN/System.err(4065): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/mnt/sdcard/mnt/sdcard/audio-android.3gp typ=audio/mp3 } 05-04 16:37:37.597: WARN/System.err(4065): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1567) 05-04 16:37:37.597: INFO/ActivityManager(92): Starting activity: Intent { act=android.intent.action.VIEW dat=/mnt/sdcard/mnt/sdcard/audio-android.3gp typ=audio/mp3 } 05-04 16:37:37.607: WARN/System.err(4065): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1537) 05-04 16:37:37.607: WARN/System.err(4065): at android.app.Activity.startActivityForResult(Activity.java:2858) 05-04 16:37:37.607: WARN/System.err(4065): at android.app.Activity.startActivity(Activity.java:2964) 05-04 16:37:37.607: WARN/System.err(4065): at com.ey.camera.AudioRecorder.playAudio(AudioRecorder.java:244) 05-04 16:37:37.607: WARN/System.err(4065): at com.ey.camera.AudioRecorder$4.onClick(AudioRecorder.java:225) 05-04 16:37:37.607: WARN/System.err(4065): at android.view.View.performClick(View.java:2408) 05-04 16:37:37.607: WARN/System.err(4065): at android.view.View$PerformClick.run(View.java:8817) 05-04 16:37:37.607: WARN/System.err(4065): at android.os.Handler.handleCallback(Handler.java:587) 05-04 16:37:37.607: WARN/System.err(4065): at android.os.Handler.dispatchMessage(Handler.java:92) 05-04 16:37:37.607: WARN/System.err(4065): at android.os.Looper.loop(Looper.java:144) 05-04 16:37:37.607: WARN/System.err(4065): at android.app.ActivityThread.main(ActivityThread.java:4937) 05-04 16:37:37.607: WARN/System.err(4065): at java.lang.reflect.Method.invokeNative(Native Method) 05-04 16:37:37.607: WARN/System.err(4065): at java.lang.reflect.Method.invoke(Method.java:521) 05-04 16:37:37.607: WARN/System.err(4065): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 05-04 16:37:37.607: WARN/System.err(4065): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-04 16:37:37.607: WARN/System.err(4065): at dalvik.system.NativeStart.main(Native Method) 

On the Galaxy tablet, it works fine. How can I solve this problem?

+73
android android-2.2-froyo galaxy-tab
May 4 '11 at 11:30 a.m.
source share
11 answers

Url addresses must be preceded by http: //

 Uri uri = Uri.parse("www.google.com"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); 

throws an ActivityNotFoundException. If you add "http: //", the problem will be resolved.

 Uri uri = Uri.parse("http://www.google.com"); 

The OP may not help, but I ended up looking for the same exception and maybe it helps others.

+133
Jun 03 2018-11-11T00:
source share
β€” -

This is the right way to do it.

  try { Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW); File file = new File(aFile.getAbsolutePath()); String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString()); String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); myIntent.setDataAndType(Uri.fromFile(file),mimetype); startActivity(myIntent); } catch (Exception e) { // TODO: handle exception String data = e.getMessage(); } 

you need to import the android.webkit.MimeTypeMap file;

+32
Jun 20 2018-11-11T00:
source share

If you also get this error when trying to open a web page from your Android application, this is because your URL looks like this:

www.google.com

instead: https://www.google.com or http://www.google.com

add this code to your activity / snippet:

  public void openWebPage(String url) { Uri webpage = Uri.parse(url); if (!url.startsWith("http://") && !url.startsWith("https://")) { webpage = Uri.parse("http://" + url); } Intent intent = new Intent(Intent.ACTION_VIEW, webpage); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } } 

just pass your openWebPage() . If it already has the https:// or http:// prefix, then you should go, otherwise the if statement handles this for you

+25
Jan 25 '17 at 10:49 on
source share

Maragues answer made me check logcat output. It appears that the path you pass to Uri should be prefixed with file:/

Since this is the local path to your repository.

You can also look too much at the path itself.

 `05-04 16:37:37.597: WARN/System.err(4065): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/mnt/sdcard/mnt/sdcard/audio-android.3gp typ=audio/mp3 }` 

The mount point appears to appear twice in the full path.

+16
Aug 25 '11 at 18:26
source share

For me, when trying to open a link:

 Uri uri = Uri.parse("https://www.facebook.com/abc/"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); 

I got the same error android.content.ActivityNotFoundException: No Activity found to handle Intent

The problem was that I did not have an application that could open the URLs (i.e. browsers) installed on my phone. Therefore, after installing the browser, the problem was resolved.

* Lesson: make sure that there is at least one application that processes the intent that you invoke *

+13
Aug 2 '16 at 7:30
source share

I had the same problem, so I considered the intent that is registered in LogCat. When watching a video in the Gallery, he named the same intent Intent.View, but set Type to "audio / *", which fixed my problem and does not require importing MimeTypeMap. Example:

 Intent intent = new Intent(android.content.Intent.ACTION_VIEW); Uri data = Uri.parse(path); intent.setDataAndType(data, "audio/*"); startActivity(intent); 
+2
Dec 19 '11 at 2:49 a.m.
source share

If you are not passing the correct web URL and you do not have a browser, an ActivityNotFoundException is raised, so check these requirements or handle the exception explicitly. This may solve your problem.

 public static void openWebPage(Context context, String url) { try { if (!URLUtil.isValidUrl(url)) { Toast.makeText(context, " This is not a valid link", Toast.LENGTH_LONG).show(); } else { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); context.startActivity(intent); } } catch (ActivityNotFoundException e) { Toast.makeText(context, " You don't have any browser to open web page", Toast.LENGTH_LONG).show(); } } 
+2
Mar 01 '18 at 9:15
source share

Was this exception even changed to

"Audio/*"

But thanks to @Stan, I got a very simple but useful solution:

Uri.fromFile(File(content)) instead of Uri.parse(path)

  val intent =Intent(Intent.ACTION_VIEW) intent.setDataAndType(Uri.fromFile(File(content)),"audio/*") startActivity(intent) 

Hope this helps someone solve his problem.

+1
Apr 23 '18 at 14:17
source share

If you have these errors in your logcat, use this code, this will help me

  Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(data.getLocation())), "audio/*"); try { context.startActivity(intent); } catch (ActivityNotFoundException e) { Log.d("error", e.getMessage()); } 

also

  Intent intent = new Intent(MediaStore.INTENT_ACTION_MUSIC_PLAYER); intent.setDataAndType(Uri.fromFile(new File(data.getLocation())), "audio/*"); try { context.startActivity(intent); } catch (ActivityNotFoundException e) { Log.d("error", e.getMessage()); } 
+1
Dec 15 '18 at 9:28
source share

Check out this useful method:

URLUtil.guessUrl(urlString)

It does google.com β†’ http://google.com

+1
Dec 19 '18 at 8:45
source share

I have two ideas:

First: if you want to play a 3gp file, you must use the mime types "audio / 3gpp" or "audio / mpeg"

And secondly: you can try using the setData(data) method for intent without any mime type.

Hope this helps.

0
May 04 '11 at 11:46
source share



All Articles