Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9181625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:21:41+00:00 2026-06-17T18:21:41+00:00

I’m trying to set an alarm manager class up so on a specified date

  • 0

I’m trying to set an alarm manager class up so on a specified date (set by a date picker) a toast style message will be displayed to the user on the specified date basically telling them their appointment is that day.

So far I have a toggle button that calls a separate class to set the alarm manager with the date, month and year variables sent to the constructor.

At the moment I’m getting the following errors:

Do I need to set an activity intent to display the message on an XML layout?

01-18 17:32:05.672: E/AndroidRuntime(271): FATAL EXCEPTION: main
01-18 17:32:05.672: E/AndroidRuntime(271): java.lang.NullPointerException
01-18 17:32:05.672: E/AndroidRuntime(271):  at com.example.flybase2.alarmset.set(alarmset.java:32)
01-18 17:32:05.672: E/AndroidRuntime(271):  at com.example.flybase2.addAppointment.onClick(addAppointment.java:68)
01-18 17:32:05.672: E/AndroidRuntime(271):  at android.view.View.performClick(View.java:2408)
01-18 17:32:05.672: E/AndroidRuntime(271):  at android.widget.CompoundButton.performClick(CompoundButton.java:99)
01-18 17:32:05.672: E/AndroidRuntime(271):  at android.view.View$PerformClick.run(View.java:8816)
01-18 17:32:05.672: E/AndroidRuntime(271):  at android.os.Handler.handleCallback(Handler.java:587)
01-18 17:32:05.672: E/AndroidRuntime(271):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-18 17:32:05.672: E/AndroidRuntime(271):  at android.os.Looper.loop(Looper.java:123)
01-18 17:32:05.672: E/AndroidRuntime(271):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-18 17:32:05.672: E/AndroidRuntime(271):  at java.lang.reflect.Method.invokeNative(Native Method)
01-18 17:32:05.672: E/AndroidRuntime(271):  at java.lang.reflect.Method.invoke(Method.java:521)
01-18 17:32:05.672: E/AndroidRuntime(271):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-18 17:32:05.672: E/AndroidRuntime(271):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-18 17:32:05.672: E/AndroidRuntime(271):  at dalvik.system.NativeStart.main(Native Method)

Heres my class that calls the ‘alarmset’ class:

package com.example.flybase2;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Spinner;
import android.widget.TimePicker;
import android.widget.ToggleButton;

 public class addAppointment extends Activity implements OnClickListener {

Spinner typeSpinner;
Button bAddAppointment;
ToggleButton balarmButton;
TimePicker setTime;
DatePicker setDate;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.addappointment);



    Spinner typeSpinner = (Spinner) findViewById(R.id.spinner1);
    List<String> list = new ArrayList<String>();
    list.add("-");
    list.add("Medical");
    list.add("Business");
    list.add("Family");
    list.add("Other");
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
        dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    typeSpinner.setAdapter(dataAdapter);


    balarmButton = (ToggleButton) findViewById(R.id.toggleButton1);
    bAddAppointment = (Button) findViewById(R.id.btnAddAppointment);
    setTime = (TimePicker) findViewById(R.id.timePicker1);
    setDate = (DatePicker) findViewById(R.id.datePicker1);


    balarmButton.setOnClickListener(this);
    bAddAppointment.setOnClickListener(this);

}

@Override
public void onClick(View clickedOption) {
    switch(clickedOption.getId()){

    case (R.id.toggleButton1):

    Integer dobYear = setDate.getYear();
    Integer dobMonth = setDate.getMonth();
    Integer dobDate = setDate.getDayOfMonth();

    alarmset setDate = new alarmset(dobYear, dobMonth, dobDate);

    setDate.set();

    break;


    case (R.id.btnAddAppointment):  

    break;

    }

And the alarmset class:

package com.example.flybase2;

import java.sql.Date;
import android.app.AlarmManager;
public class alarmset {
    Integer yearSet;
    Integer monthSet;
    Integer dateSet;

    AlarmManager am;

    public alarmset(Integer dobYear, Integer dobMonth, Integer dobDate) {
        yearSet = dobYear;
        monthSet = dobMonth;
        dateSet = dobDate;
    }

    public void set() {
        Date set;
        set = new Date(yearSet - 1900, monthSet, dateSet);
        am.set(AlarmManager.RTC_WAKEUP, set.getTime(), null);   
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:21:43+00:00Added an answer on June 17, 2026 at 6:21 pm

    In your alarmset class, you have this line:

    am.set(AlarmManager.RTC_WAKEUP, set.getTime(), null);
    

    You never instantiate the variable am. It will always be null when you reach the line that I mentioned, so you will throw a NullPointerException. You need to instantiate it, either by passing in and assigning a value, or via new AlarmManager() or another related constructor.

    Also, as a matter of style, class names should be capitalized. Eg. Alarmset or AlarmSet instead of alarmset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.