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.