我们的广告系统,为了防止被客户关闭,必须要每隔一段时间启动一次。
创建一个Service:
最关键的是onStartCommand 里面返回的Service.START_STICKY,
return Service.START_STICKY
package com.wbm.app.servicetest.servic;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import java.util.List;
public class StartService extends Service implements Runnable{
private Thread thread;
public StartService() {
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
//throw new Unsuppor