浏览器未加载

时间:2013-06-05 12:47:53

标签: android

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

1 个答案:

答案 0 :(得分:1)

请确保您的detailsToBrowse以“http://”或“https://”开头

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

并改变你的方法

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