Skip to content
Advertisement

Consider adding a “ declaration to your manifest when calling this method;

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);
                }
            }
        });

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement