用法1:

MainActivity.java

Intent intent = new Intent();

intent.setClass(getApplicationContext(), MyService.class);

startService(intent);

AndroidManifest.xml

<service

android:name="com.example.first.MyService"

android:enabled="true" >

</service>

蓝色:还可是.MyService、MyService

用法2:

MainActivity.java

Intent intent = new Intent();

intent.setAction("com.example.first.MyService");

startService(intent);

AndroidManifest.xml

<service

android:name="com.example.first.MyService"

android:enabled="true" >

<intent-filter>

<action android:name="com.example.first.MyService" />

</intent-filter>

</service>

蓝色:还可是.MyService、MyService

红色:两处保持一致

更多相关文章

  1. android 颜色16进制对应的xml配置值(工具参考)
  2. Intent在Android中的几种用法 .
  3. Android(安卓)handler用法详解二(例2)
  4. android 6.0权限问题处理的核心代码--shouldShowRequestPermissi
  5. Android(安卓)IntentService用法和源码分析
  6. Android(安卓)传感器用法
  7. Android(安卓)中数据库查询方法query()中的selectionArgs的用法
  8. Android(安卓)DownloadManager 用法
  9. android 中RecyclerView 嵌套了 GridView 的用法

随机推荐

  1. Android中的资源与国际化!
  2. Android(安卓)VCard通讯录导入导出详解
  3. [置顶] Android之高仿手机QQ聊天
  4. 网络界面Android(安卓)网络连接--Wifi/3G
  5. Android中Intent的显示和隐式使用
  6. Android之WebView优化之路
  7. Android自定义控件一简介
  8. 《第一行代码》学习笔记一
  9. android软键盘的用法总结
  10. Android(安卓)wifi驱动的移植 realtek 81