//定义Intent通过给定的ACTION来启动服务
Intent intent=new Intent();
intent.setAction(MyService.ACTION);
startService(intent);
//service的部分代码
public class MyService extends Service {
public static final String ACTION = "com.example.codetest_1.action.startPlayService";
//清单文件
<service
android:name=".MyService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.example.codetest_1.action.startPlayService" />
</intent-filter>
</service>
我实在看不出什么问题了= =一点按钮程序就结束
I/Process: Sending signal. PID: 17843 SIG: 9
Application terminated.