每日随笔2023/3/8

今天学习了As中的显隐式Intent

 

三种构建方式:

在Intent的构造函数中指定

调用意图对象的setClass方法指定

调用意图对象的setComponent方法指定

(1)

Intent intent = new Intent(MainActivity.this, MainActivity2.class);

(2)

  Intent intent = new Intent();
                intent.setClass(MainActivity.this,MainActivity2.class);

(3)

Intent intent = new Intent();
                ComponentName componentName = new ComponentName(MainActivity.this,MainActivity2.class);
                intent.setComponent(componentName);

 

posted @ 2023-03-08 17:33  花伤错零  阅读(16)  评论(0)    收藏  举报