manish
manish

Reputation: 1458

Browser is not being loaded

public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_browser_detail);
  Bundle browserDetailBundle =  getIntent().getExtras();
  if(browserDetailBundle!= null)
  {
    detailsToBrowse = browserDetailBundle.getString("EditTextContent");
    if (!detailsToBrowse.startsWith("http://") && !detailsToBrowse.startsWith("https://"))
      detailsToBrowse = "http://" + detailsToBrowse;    
    viewToBrowse = (View)findViewById(R.id.editTextBrowser);
  }
  callMe(viewToBrowse);
}

public void callMe(View v){
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(detailsToBrowse));
    startActivity(i);
}

Upvotes: 0

Views: 55

Answers (1)

Rigotti
Rigotti

Reputation: 2862

Make sure, yours detailsToBrowse begins with "http://" or "https://"

if (!detailsToBrowse.startsWith("http://") && !detailsToBrowse.startsWith("https://"))
    detailsToBrowse = "http://" + detailsToBrowse;

And change your method

public void callMe(View v){
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(detailsToBrowse);
    startActivity(i);
}

Upvotes: 1

Related Questions