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);
}
问问题
52 次
1 回答
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);
}
于 2013-06-05T16:28:08.483 回答