我:<service android:name=".kernel.background.Process"></service>
主要包:package="call.com"
安卓:我的服務並不想開始
我想創建一個過程至極將strart同步方法我的數據庫,現在我發現了一些例子,但..
這是我的後臺進程:
package call.com.kernel.background;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
public class Process extends Service {
private final Timer timer = new Timer();
@Override
public void onCreate() {
super.onCreate();
startservice();
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
private void startservice() {
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
System.out.println("time:");
System.out.println("is:");
System.out.println("up:");
}
}, 0, 1000);
;
}
private void stopservice() {
if(timer != null) {
timer.cancel();
}
}
}
你遇到了什麼錯誤?請發佈Logcat的輸出。 –
我沒有得到錯誤,我只是把斷點,我看到,我從來沒有去這項服務。 //我指出:onCreate和定時器內部,我沒有看到任何像System.out.print .. – Nayden
你打電話給這個服務? 您是使用意圖還是從應用程序的根目錄開始? –