Intent 显示与隐式了解认识

显示Intent

用于精确匹配,指定跳转目标

1.在intent构造函数中调用

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

2.调用意图对象的setClass

Intent intent =new Intent();

intent.setClass(this,XX.class);

3.调用意图对象的setComponent

Intent intent =new Intent();

ComponentName component = new ComponentName(this,XX.class);

intent.setComponent(component);

startActivity(intent);

 

隐式Intent

没有指出明确跳转目标,只给出一个动作字符串让系统匹配,属于模糊匹配

 

 一个简单的实例

 

posted @ 2023-02-03 17:30  天启A  阅读(32)  评论(0)    收藏  举报