ここに私の WallePapeAuto.java コードがあります:
package com.demo.wallpaper;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
public class WallePapeAuto extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(WallePapeAuto.this, BackgroundService.class);
startService(intent);
}
}
ここに私の BackgroundService.java コードがあります:
package com.demo.wallpaper;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
public class BackgroundService extends Service{
final String TAG = "BackgroundService";
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId){
Log.i(TAG,"onStart launched");
Timer timer = new Timer();
TimerTask timerTask = new TimerTask(){
@Override
public void run() {
// TODO Auto-generated method stub
Log.i(TAG,"timerTask launched");
checkStatus();
}
};
timer.scheduleAtFixedRate(timerTask,15000,15000); //call after every 15 sec
super.onStart(intent, startId);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG,"onStartCommand");
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onCreate() {
Log.i(TAG,"onCreate");
super.onCreate();
}
@Override
public void onDestroy() {
Log.i(TAG,"onDestroy");
super.onDestroy();
}
public void checkStatus(){
try{
Log.i(TAG,"in checking status...");
} catch (Exception e){
Log.i(TAG, "Error occur during checking status");
e.printStackTrace();
}
}
}
私の AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.wallpaper"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.demo.wallpaper.WallePapeAuto"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:enabled="true"
android:name=".BackgroundService" />
</application>
</manifest>
実行するとログ値の一部が表示されると思いますが、Logcat には何もありません。どの部分を間違えたのかわかりません。どんな助けでも感謝します。前もって感謝します。