您的位置:首页 > 移动开发 > Android开发

Android intent

2009-09-03 15:01 393 查看
1. Explicit intent:

-- In the same application

Intent intent = new Intent(this, TestActivity.class);

startActivity(intent);

//startService(intent);

-- In differenct application

Intent intent = new Intent();

intent.setClassName("com.china.testapp", "com.china.testapp.TestActivity");

startActivity(intent);

//startService(intent);

2. Implicit intent:

Intent intent = new Intent("com.china.testapp.MYACTION");

startActivity(intent);

//startService(intent);

--OR

Intent intent = new Intent();

intent.setAction("com.china.testapp.MYACTION");

startActivity(intent);

//startService(intent);

--API reference:

public Intent (String action)

Create an intent with a given action. All other fields (data, type, class) are null. Note that the action must be in a namespace because Intents are used globally in the system -- for example the system VIEW action is android.intent.action.VIEW; an application's custom action would be something like com.google.app.myapp.CUSTOM_ACTION.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: