私のプロジェクトでは、私はアラームコードを使用しています。エラーはありませんが、BroadcastReceiver
クラス内のものは実行されていません。私はどこに欠陥があるのか分からない。 Eclipseを使用してWindowsで実行しています。 AndroidManifest.xmlに<receiver>
クラスも指定しました。Androidでアラームを受信
BroadcastReceiver
クラスのコードを実行します。この場合、指定された時刻に受信者クラスに表示されるテキストを表示する必要があります。 これは私のレシーバクラスです:
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.registerReceiver(null, null);
Toast.makeText(context, "Time is
up!!!!.",Toast.LENGTH_LONG).show();
}}
誰もがこの問題を取り除くための方法を提案することはできますか? ありがとうございます!
のAndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.project.rappel"
android:versionCode="1"
android:versionName="1.0">
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
<provider
android:name="ScheduleProvider"
android:authorities="com.project.rappel" />
<activity
android:name=".Rappel"
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=".SetSchedule"></activity>
<activity
android:name=".DaysAndTimes"></activity>
<activity
android:name=".Tts"></activity>
<receiver
android:name="MyBroadcastReceiver"
android:process=":remote" />
</application>
<uses-sdk
android:minSdkVersion="8" />
</manifest>
以上が私のandroidmanifest.xml.Thisは、私はReceiverをtrigerringに使用されるコードです。
public void startAlert(View view) {
EditText text = (EditText) findViewById(R.id.time);
int i = Integer.parseInt(text.getText().toString());
Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
+ (i * 1000), pendingIntent);
Toast.makeText(this, "Alarm set in " + i + " seconds",
Toast.LENGTH_LONG).show();
}
AndroidManifest.xmlを表示してください – ccheneson
あなたは、受信機を起動する必要があると思われるコードを投稿したいと思うかもしれません。 –
私のアンドロイドマニフェストと私のポストにアラームをトリガするためのコードが含まれています... – Kiruthika