2012-03-27 75 views
0

我在我的活動中有一個按鈕,我想按下時啓動一個意圖,將啓動一些頁面就像一個「我很幸運」谷歌開始意圖打開谷歌鏈接就像我感覺幸運按鈕

意思是這樣的

public void startIntent(String textToSearch){ 
//fire an intent that will open the page just like when I open 
//google.com and enter the textToSearch text and press I am feeling lucky 
} 

我怎樣才能做到這一點?

+0

是這樣的:http://stackoverflow.com/questions/4800575/start-google-search-query-from-activity-android。例如將一些變量傳遞給您打開的網址 – 2012-03-27 08:56:28

回答

1

這是我需要

public void startIntent(String textToSearch){ 
Uri uri = Uri.parse("http://www.google.com/#q="+textToSearch); 
Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
startActivity(intent); 
}