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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:23:13+00:00 2026-06-01T02:23:13+00:00

I am new to Android. I have tried an sample application for status bar

  • 0

I am new to Android. I have tried an sample application for status bar reminder for mentioning date. But it is not working in Emulator, i don’t know what i am missing. I have attached the sample code here

Main.java

Calendar cal = Calendar.getInstance();       
    cal.set(Calendar.MONTH, 3);
    cal.set(Calendar.YEAR, 2012);               
    cal.set(Calendar.DAY_OF_MONTH, 25);
    cal.set(Calendar.HOUR_OF_DAY, 22);
    cal.set(Calendar.MINUTE, 8);
    cal.set(Calendar.SECOND,0);
    Intent alarmintent = new Intent(getApplicationContext(), AlarmReceiver.class);
    PendingIntent sender = PendingIntent.getBroadcast(getApplicationContext(), 1,alarmintent,PendingIntent.FLAG_UPDATE_CURRENT|  Intent.FILL_IN_DATA);
    am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);

In the alarm receiving class i have the following code

AlarmReceiver.java

 public class AlarmReceiver extends BroadcastReceiver {
 NotificationManager nm;
 public void onReceive(Context context, Intent intent) {
 nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
 CharSequence from = "Raja";
 CharSequence message = "My First App...";
 PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(), 0);
 Notification notif = new Notification(R.drawable.ic_launcher,"Crazy About Android...", System.currentTimeMillis());
 notif.setLatestEventInfo(context, from, message, contentIntent);
  nm.notify(1, notif);
  }
 }

In the manifest file i have added the following line (before the application tag close) for Alarm receiving class

  <receiver android:name=".AlarmReceiver"></receiver>

Log cat entries


    03-28 00:11:18.411: I/ActivityManager(69): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.raja.sample/.Main } from pid 556
03-28 00:11:18.481: I/ActivityManager(69): Start proc com.raja.sample for activity com.raja.sample/.Main: pid=564 uid=10036 gids={}
03-28 00:11:18.491: D/AndroidRuntime(556): Shutting down VM
03-28 00:11:18.512: D/dalvikvm(556): GC_CONCURRENT freed 102K, 69% free 319K/1024K, external 0K/0K, paused 1ms+1ms
03-28 00:11:18.552: D/dalvikvm(556): Debugger has detached; object registry had 1 entries
03-28 00:11:18.571: I/AndroidRuntime(556): NOTE: attach of thread 'Binder Thread #3' failed
03-28 00:11:19.352: I/IMFO(564): RAKAAAAAAAAAAAAA
03-28 00:11:19.611: I/ActivityManager(69): Displayed com.raja.sample/.Main: +1s147ms
03-28 00:11:20.101: W/InputManagerService(69): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@4061d080 (uid=10035 pid=532)
03-28 00:11:24.751: D/dalvikvm(247): GC_EXPLICIT freed 7K, 54% free 2544K/5511K, external 1625K/2137K, paused 97ms
03-28 00:13:28.577: D/SntpClient(69): request time failed: java.net.SocketException: Address family not supported by protocol
  • 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-01T02:23:14+00:00Added an answer on June 1, 2026 at 2:23 am
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(), 0);
    

    You are passing a blank Intent here . Change this to the intent of Activity you want to all, for example :

    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(context,MyActivity.class), 0);
    

    Try the following Activity:

    public class TestAlarmActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
         // get a Calendar object with current time
            Calendar cal = Calendar.getInstance();
            // add 5 minutes to the calendar object
            cal.add(Calendar.MINUTE, 5);
            Intent intent = new Intent(this, AlarmReceiver.class);
            intent.putExtra("alarm_message", "O'Doyle Rules!");
            // In reality, you would want to have a static variable for the request code instead of 192837
            PendingIntent sender = PendingIntent.getBroadcast(this, 192837, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    
            // Get the AlarmManager service
            AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
            am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+5000, sender);
            Toast.makeText(this, "tii;;; inside", Toast.LENGTH_LONG).show();
        }
    

    and the following Broadcastreceiver:

    public class AlarmReceiver extends BroadcastReceiver {
    
        private NotificationManager nm;
    
        @Override
        public void onReceive(Context context, Intent arg1) {
            // TODO Auto-generated method stub
            Toast.makeText(context, "inside", Toast.LENGTH_LONG).show();
            nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
             CharSequence from = "Raja";
             CharSequence message = "My First App...";
             PendingIntent contentIntent = PendingIntent.getActivity(context, 0,new Intent(), 0);
             Notification notif = new Notification(R.drawable.ic_launcher,"Crazy About Android...", System.currentTimeMillis());
             notif.setLatestEventInfo(context, from, message, contentIntent);
              nm.notify(1, notif);
        }
    

    I think your alarm is not getting executed because it has already passed as you are passing day of month as 25

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

Sidebar

Related Questions

Ok, im fairly new to android but i have managed to teach myself the
I am new to android widget.I did sample application , that want to show
As I'm new to OpenGL programming, I have tried to test the sample code
i'm new at Android world, and i have a doubt, is there any method
I am completely new to android, and pretty much a Java newb. I have
I have to admit that I'm new to Java and Android. db4o seems to
I have this code on my Android phone. URI uri = new URI(url); HttpPost
I am new to android platform. I am working on a project in which
I want to get fling gesture detection working in my Android application. What I
I'm working on my first android app and have an SQLite database set up

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.