1

I am getting this warning on resolveActivity line while using implicit intents and I am unable to open any website because of that.

btnWeb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String v = et.getText().toString();
                Uri uri = Uri.parse(v);
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                if (intent.resolveActivity(getPackageManager())!=null){
                    startActivity(intent);
                }
            }
        });
a_local_nobody
  • 7,947
  • 5
  • 29
  • 51

1 Answers1

1

Get rid of resolveActivity(). Just call startActivity(), but do so in a try/catch, so you can catch the ActivityNotFoundException if there is no Web browser available.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491