-1

I have a webView app. Is a list of links to some tv online streaming channels.

Some links are m3u8 and others are sop.

If I access a m3u8 link it opens in default media player, if i try to open the sop links, and I do not have SopCast Player installed, my app crashes, and I got the error below.

If I have installed SopCast Player, evetrything is ok.

I'm now with Android.

My files: Manifest

ManinActivity

Error:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=sop://111.175.143.195:3912/151638 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
at android.app.Activity.startActivityForResult(Activity.java:2827)
at android.app.Activity.startActivity(Activity.java:2933)
at com.example.tv.MainActivity$1.shouldOverrideUrlLoading(MainActivity.java:47)
at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:239)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:346)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3735)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
at dalvik.system.NativeStart.main(Native Method)

Please, please, please, help me!! Sorry for my english.

3 Answers3

1

It crashes because the app is not installed. What did you expect would happen?

You need to first check if the package is installed before calling the Intent.

nhaarman
  • 98,571
  • 55
  • 246
  • 278
0

The error is pretty much self-explanatory. the Android system doesn't know how to handle that URL.

You can just wrap your

   startActivity(i);

in a try/catch-block (and inform the user of the problem in catch), or you can check beforehand if the system can handle that Intent as outlined here.

Community
  • 1
  • 1
fweigl
  • 21,278
  • 20
  • 114
  • 205
-1

In your shouldOverrideUrlLoading() you should replace startActivity(i); with

try {
  startActivity(i);
} catch (ActivityNotFoundException e) {
  // do what you want if appropriate app is not installed
}
praetorian droid
  • 2,989
  • 1
  • 17
  • 19