Home > database >  Consider adding a `<query>` declaration to your manifest when calling this \method;
Consider adding a `<query>` declaration to your manifest when calling this \method;

Time:11-29

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

CodePudding user response:

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.

  • Related