开始意图打开谷歌链接就像我感觉幸运按钮

时间:2012-03-27 08:53:31

标签: android android-intent

我的活动中有一个按钮,我想在按下的时候发出一个意图,这个意图就像一个"我感觉很幸运"在谷歌上

意思是这样的

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
}

我该怎么做?

1 个答案:

答案 0 :(得分: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);
}