次のコードでどのようなばかげた間違いを犯し、エラーが発生したのか誰にもわかりますか。
同様のstackoverflowの投稿とサンプルを試しました。
エラー: 06-24 09:06:36.074: W/ActivityManager(61): サービスを開始できません Intent { flg=0x4 cmp=com.example.myapp/.Updater (エクストラがあります) }: 見つかりません
package com.example.myapp;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
public class Booter extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.e("boot-status","BOOT_COMPLETED==========================");
// SharedPreferences prefs = context.getSharedPreferences("$MYPACKAGE_preferences",0);
// if (prefs.getBoolean("startatboot",false)) {
if(true){
Intent updateIntent = new Intent();
updateIntent.setClass(context, Updater.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, updateIntent, 0);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, java.lang.System.currentTimeMillis()+60000, pendingIntent);
}
}
}
}
Updater.class
package com.example.myapp;
import android.os.Bundle;
import android.util.Log;
import android.util.Log;
public class Updater {
public void onCreate() {
Log.e("app-status","ping =====================================================================");
}
}
メニフェスト
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.myapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myapp.SettingsActivity"
android:label="@string/title_activity_settings" >
</activity>
<receiver android:name="Booter" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
</application>
</manifest>