为什么我写的Android闹钟到时间时却不会响

我在写Android闹钟时用如下代码:

Intent i=new Intent(AddInform.this,CallAlarm.class);
      PendingIntent sender=PendingIntent.getBroadcast(AddInform.this, 0, i, 0);
      AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
      am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), sender);

却忘记了在AndroidManifest.xml当中声明了这一句话:

<receiver android:name=".CallAlarm" android:process=":remote"/>

这句话的具体位置就放在:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="
http://schemas.android.com/apk/res/android"
    package="com.my.alarm01"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <receiver android:name=".CallAlarm" android:process=":remote"/>
        <activity
            android:name=".AlarmTest01"
            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=".AlarmAlert"></activity>
    </application>
    <uses-permission android:name="android.permission.SEND_SMS"/>

</manifest>

 

 

你可能感兴趣的:(为什么我写的Android闹钟到时间时却不会响)