Android中Intent对象提供许多属性:

  • ComponentName
  • Action
  • Flags
  • Extras
  • Catgory
  • Data

其中,ComponentName可以启动Activity、Service。
第一个参数为应用包名,另一个参数为要启动的Activity或服务所在包名+类名。

 Intent intent = new Intent(); //Activity ComponentName componentName=new ComponentName("com.example.componentname","com.example.componentname.DetailActivity"); /*Service ComponentName componentName=new ComponentName("com.example.componentname","com.example.componentname.DetailService")*/ intent.setComponent(componentName); startActivity(intent); //startService(intent);
 

更多相关文章

  1. mybatisplus的坑 insert标签insert into select无参数问题的解决
  2. Python技巧匿名函数、回调函数和高阶函数
  3. python list.sort()根据多个关键字排序的方法实现
  4. Android应用程序(activity)启动过程(二)
  5. Android面试题集锦 (陆续更新)
  6. android UI 小知识点
  7. 怎么给Android(安卓)控件添加边框(样式)?
  8. Android中attrs.xml文件的使用详解
  9. attrs.xml的使用

随机推荐

  1. android之获取当前日期所属的本周、本月
  2. Android两种轮询的实现方法
  3. Android 增加LOG
  4. 实现TextView在内容过多时自动滚动
  5. 滑动抽屉SlidingDrawer
  6. android之广播
  7. Android 几种加密解密的方法(仅代码)
  8. Android如何调用系统相机拍照
  9. android studio (mac) 快捷键
  10. RxJava 2: 用Retrofit2架构Android(安卓)