/* 首先指定Intent的action是Intent.ACTION_VIEW,這是android系統內置的動作,
常量值為android.intent.action.VIEW。然后通過Uri.parse()方法,將一個網址字符串解析為Uri對象,
再調用Intent的setData()方法將這個Uri對象傳遞出去 */ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.baidu.com")); startActivity(intent);
其中,setData()方法為接收一個Uri對象(Uri的定義在文章https://www.cnblogs.com/chengyangblog/p/15167389.html),用於指定當前Intent正在操作的數據,而這些數據通常都是以字符串的形式傳入到Uri.parse()方法中解析產生。