service的隐式启动和显示启动

来源:互联网 发布:c语言黑客编程pdf 编辑:程序博客网 时间:2024/06/08 04:51
 

隐式启动
<service android:name=".service">
<intent-filer>
<action android:name="com.android.service"/>
<intent-filer>
</service>
final Intent serviceIntent=new Intent();
serviceIntent.setAction("com.android.service");
显示启动
final Intent serviceIntent=new Intent(this,service.class);
startService(serviceIntent);
如果在同一个包中。两者都可以用。在不同包时。只能用隐式启动