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