intent是什么东西呢,在我看来,它是一个通知android执行下一个功能或是服务的一个消息机制。官方的意思是:intent是用来调用组件的一个概念,组件包括Activities、Sevices、ContentProviders、BroadcastReceivers。
下面是英文:
Android introduced a concept called intents to invoke components. The list ofcomponents in Android includes activities (UI components), services (background code),
broadcast receivers (code that responds to broadcast messages), and content providers
(code that abstracts data).
具体在代码中像这样用:
public static void showWebBrowser(Activity activity){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.google.com"));
activity.startActivity(intent);
}
上面这段代码是打开网页浏览器,首页为google。参数为activity是因为intent是由activity到另外一个activity的“通知器”。