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 981299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:31:14+00:00 2026-05-16T04:31:14+00:00

Ok, I’ve tried two examples of AlarmManager- one from the commonsware website, and one

  • 0

Ok, I’ve tried two examples of AlarmManager- one from the commonsware website, and one from the manning website.
The code I am currently working with is from the manning website : [http://unlocking-android.googlecode.com/svn/chapter8/trunk/SimpleAlarm/%5D%5B1%5D

There are two classes, AlarmReceiver and GenerateAlarm. Anyone have any idea why the toast will not display in the emulator? I was thinking that it was because I am located in the Eastern Time Zone and it uses UTC, but I have fiddled with different things and none of them seem to work.

public class GenerateAlarm extends Activity {

Toast mToast;

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    Button button = (Button) findViewById(R.id.set_alarm_button);
    button.setOnClickListener(this.mOneShotListener);
}

private OnClickListener mOneShotListener = new OnClickListener() {

    public void onClick(View v) {

        Intent intent = new Intent(GenerateAlarm.this, AlarmReceiver.class);

        PendingIntent appIntent = PendingIntent.getBroadcast(GenerateAlarm.this, 0, intent, 0);

        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
       // calendar.add(Calendar.MINUTE, 1);
        calendar.add(Calendar.SECOND, 10);

        AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), appIntent);

        if (GenerateAlarm.this.mToast != null) {
            GenerateAlarm.this.mToast.cancel();
        }
        GenerateAlarm.this.mToast = Toast.makeText(GenerateAlarm.this, R.string.alarm_message, Toast.LENGTH_LONG);
        //GenerateAlarm.this.mToast.show();
    }
};

}

public class AlarmReceiver extends BroadcastReceiver {

public void onReceiveIntent(Context context, Intent intent) {
    Toast.makeText(context, R.string.app_name, Toast.LENGTH_SHORT).show();
}

@Override
public void onReceive(Context context, Intent intent) {

}
}
  • 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-05-16T04:31:16+00:00Added an answer on May 16, 2026 at 4:31 am

    You have to add your toast in the onReceived method where you should add the handling of the intent received.

    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, R.string.app_name, Toast.LENGTH_SHORT).show();
    }
    

    onReceiveIntent is not a method of broadcastreceiver

    public abstract void onReceive
    (Context context, Intent intent)

    Since: API Level 1 This method is
    called when the BroadcastReceiver is
    receiving an Intent broadcast.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.