私の主な活動では、これを実行しています:
Calendar calendar = Calendar.getInstance();
// 9:45 PM
calendar.set(Calendar.HOUR_OF_DAY, 21);
calendar.set(Calendar.MINUTE, 45);
calendar.set(Calendar.SECOND, 0);
AlarmManager am = (AlarmManager) this.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
PendingIntent pi = PendingIntent.getService(this.getApplicationContext(), 0, new Intent(this.getApplicationContext(), MorningReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pi);
Toast msg = Toast.makeText(NotificationScanner.this,
"Scheduled: " + calendar.getTime(), Toast.LENGTH_LONG);
msg.show();
そして、これは私の受信機です
public class MorningReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
MediaPlayer mMediaPlayer = new MediaPlayer();
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
try {
mMediaPlayer.setDataSource(context, alert);
final AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) {
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
mMediaPlayer.start();
PackageManager packageManager = context.getPackageManager();
Intent skype = packageManager.getLaunchIntentForPackage("com.skype.raider");
context.startActivity(skype);
}
}catch(Exception e){
Toast msg = Toast.makeText(context,
"Exception thrown", Toast.LENGTH_LONG);
msg.show();
}
}
}
そして、これは私の AndroidManifest.xml です
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wayward.skype.wizard"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".SkypeActivity"
android:label="@string/title_activity_skype" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.wayward.service.NotificationScanner" >
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
<receiver android:name="com.wayward.service.MorningReceiver" >
</receiver>
</application>
MorningReceiver を開こうとすると、次のエラーが発生します。
Unable to start service Intent { flg=0x4 cmp=com.wayward.skype.wizard/com.wayward.service.MorningReceiver (has extras) }: not found
ここで私が間違っていると宣言していることを誰か知っていますか?または、私が間違っていることは何ですか?