PSchuette
PSchuette

Reputation: 4473

Trouble with Intent for AlarmManager

Hey, so I have been making an application which sends weekly notifications at user-specified times.

I have followed plenty of tutorials and seem to have read the same thing over and over, I just cant seem to get it to work. My application crashes when I call the new intent. Am I doing something wrong? is this the correct method of accomplishing this task?

public class AlarmService extends Activity
{ 

    /// unimportant working code not added

    Intent mintent = new Intent(context, mBroadcastReceiver.class);
    Log.d(TAG, "Got Intent");
    /// I receive a log just before this portion but do not receive this one

    startActivity(PAintent);
    Log.d(TAG, "StartActivity(intent)");

    PendingIntent mPendingIntent = PendingIntent.getActivity(getApplicationContext(), ALARMID,
        mintent, PendingIntent.FLAG_CANCEL_CURRENT);
    Log.d(TAG, "Got Pending intent");

    AlarmManager mAlarm = (AlarmManager) getSystemService(ALARM_SERVICE);
    Log.d(TAG, "Got alarmmanager");

    ///// remember to change time back to: (7 * 24 * 60 * 60 * 1000)
    mAlarm.setRepeating(AlarmManager.RTC_WAKEUP,
    ALARM_TIME.getTimeInMillis(), (30 * 1000),
    mPendingIntent);
    Log.d(TAG, "Made Pending intent");
    ...
}

keep in mind I renamed my intent, pendingintent, and alarm manager in this code for easier reading!

I keep receiving a null pointer exception, my debug looks like this:

03-05 13:20:45.132: E/AndroidRuntime(12734): FATAL EXCEPTION: main
03-05 13:20:45.132: E/AndroidRuntime(12734): java.lang.NullPointerException
03-05 13:20:45.132: E/AndroidRuntime(12734):    at android.content.ComponentName.<init>(ComponentName.java:75)
03-05 13:20:45.132: E/AndroidRuntime(12734):    at android.content.Intent.<init>(Intent.java:2720)
03-05 13:20:45.132: E/AndroidRuntime(12734):    at com.theStudyBuddy.Ignite.AlarmService.PlannerAssistantOn(AlarmService.java:148)
03-05 13:20:45.132: E/AndroidRuntime(12734):    at com.theStudyBuddy.Ignite.EditScheduleActivity.saveClass(EditScheduleActivity.java:635)
03-05 13:20:45.132: E/AndroidRuntime(12734):    at com.theStudyBuddy.Ignite.EditScheduleActivity.onClick(EditScheduleActivity.java:583)
03-05 13:20:45.132: E/AndroidRuntime(12734):    at android.view.View.performClick(View.java:2485)

... and so on

if anyone could point out my error it would be greatly appreciated!

Upvotes: 0

Views: 206

Answers (1)

secretlm
secretlm

Reputation: 2361

startActivity(PAintent); where is PAintent? Do you create it?

To start a Scheduled Activity: you can see this link: Android : AlarmManager not start

Upvotes: 1

Related Questions