new Thread(new Runnable() {
@Override
public void run() {
CFileLog.i("xg", "new Thread(new Runnable()");
final Message msg = new Message();
Intent bootActivityIntent=new Intent( ApplicationConstants.myServiceName);//启动服务
MainActivity.this.startService(bootActivityIntent);
msg.arg1 = R.string.service_startup;
toaster.sendMessage(msg);
}
}).start();
myServiceName变量所对应的服务中,OnCreate,OnStartCommand都有打印日志出来。
在这里启动了我的服务,但是我发现在服务中的OnStart,OnStartCommand函数中过了一段时间也会启动。但是从来没运行到OnDestroy里面。也就是服务myServiceName在不断的重启,但后面的启动却不是又上面的startService启动的(因为没打印到这里的日志),请问有没有人知道怎么回事? 下面是配置文件中myServiceName的配置:
<service android:name=".manager.myMobileService" android:enabled="true">
<intent-filter>
<action android:name="com.xxx.manager.myMobileService"></action>
</intent-filter>
</service>
@Override
public void run() {
CFileLog.i("xg", "new Thread(new Runnable()");
final Message msg = new Message();
Intent bootActivityIntent=new Intent( ApplicationConstants.myServiceName);//启动服务
MainActivity.this.startService(bootActivityIntent);
msg.arg1 = R.string.service_startup;
toaster.sendMessage(msg);
}
}).start();
myServiceName变量所对应的服务中,OnCreate,OnStartCommand都有打印日志出来。
在这里启动了我的服务,但是我发现在服务中的OnStart,OnStartCommand函数中过了一段时间也会启动。但是从来没运行到OnDestroy里面。也就是服务myServiceName在不断的重启,但后面的启动却不是又上面的startService启动的(因为没打印到这里的日志),请问有没有人知道怎么回事? 下面是配置文件中myServiceName的配置:
<service android:name=".manager.myMobileService" android:enabled="true">
<intent-filter>
<action android:name="com.xxx.manager.myMobileService"></action>
</intent-filter>
</service>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货