Android.content.ActivityNotFoundException: passing url to intent

I have the following error in my application:

Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://m.fretebras.com.br/fretes }
   at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
   at android.app.Activity.startActivityForResult(Activity.java:3468)
   at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
   at android.app.Activity.startActivityForResult(Activity.java:3429)
   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
   at android.app.Activity.startActivity(Activity.java:3671)
   at android.app.Activity.startActivity(Activity.java:3639)
   at br.lgfelicio.atividades.Checkin.acaoBotao(Checkin.java:773)
   at br.lgfelicio.atividades.Checkin$12.onClick(Checkin.java:312)
   at android.view.View.performClick(View.java:4461)
   at android.view.View$PerformClick.run(View.java:18543)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5118)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
   at dalvik.system.NativeStart.main(NativeStart.java)

Error code:

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.fretebras.com.br/fretes"));
startActivity(i);

The error occurs in versions 6.0.1 of android, I have no idea why this is happening, I believe that passing the URL is Intentall right. Can anybody help me?

+4
source share
1 answer

It looks like your browser doesn’t have a browser installed. Please check and avoid using the crash code below the code.

try {
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.fretebras.com.br/fretes"));
        startActivity(i);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }

Note . This code simply ignores your failure if the browser is not found.

+5
source

Source: https://habr.com/ru/post/1658921/


All Articles