BrodcastReceiver not working : Android

I am implementing a sample code for BrodcastReceiver, where it will start from a specific time, but there is something problem in my code and its not working..

Here is my code :

In Activity :

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Calendar cur_cal = new GregorianCalendar(TimeZone.getTimeZone("IST"), Locale.US); cur_cal.setTimeInMillis(System.currentTimeMillis()); Calendar cal = new GregorianCalendar(); cal.add(Calendar.DAY_OF_YEAR, cur_cal.get(Calendar.DAY_OF_YEAR)); cal.add(Calendar.HOUR_OF_DAY, 13); cal.add(Calendar.MINUTE, 10); cal.add(Calendar.SECOND, 00); cal.add(Calendar.MILLISECOND, 0); cal.add(Calendar.DATE, 31); cal.add(Calendar.MONTH, 10); Intent intent = new Intent(HelloAlarmManagerActivity.this, ScheduleHandler.class); PendingIntent pIntent = PendingIntent.getBroadcast(HelloAlarmManagerActivity.this, 0, intent, 0); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 2*10, pIntent); Toast.makeText(HelloAlarmManagerActivity.this, "Alarm seted", Toast.LENGTH_SHORT).show(); }

and my BrodcastReceiver class is as :

public class ScheduleHandler extends BroadcastReceiver { /* (non-Javadoc) * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent) */ @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Toast.makeText(context, "Alarm called", Toast.LENGTH_SHORT).show(); } }

After running this application, I am getting only first toast message. It means broadcast receiver not getting called.

Is there any problem in my code?

-------------Problems Reply------------

It looks like your Repeat interval is 20 (2*10) milliseconds. I have no Idea how phones would react to that, but It might be the cause of your problem

Category:android Views:0 Time:2011-10-31

Related post

  • How to implement event method in JNI Android imported class to XE5 2014-03-26

    I am interested in implementation of event method in imported interface of JAVA class to Delphi XE5. Example: Imagine we want to use JBroadcastReceiver from Androidapi.JNI.GraphicsContentViewText. There is a event method: procedure onReceive(context:

  • Using ItemizedOverlay and OverlayItem In Android Beta 0.9 2008-08-25

    Has anyone managed to use ItemizedOverlays in Android Beta 0.9? I can't get it to work, but I'm not sure if I've done something wrong or if this functionality isn't yet available. I've been trying to use the ItemizedOverlay and OverlayItem classes. T

  • Proxy which requires authentication with Android Emulator 2008-08-26

    Has anybody managed to get the Android Emulator working behind a proxy which requires authentication? I've tried setting the -http-proxy argument to http://DOMAIN/USERNAME:[email protected]:PORT but am having no success. I've tried following the docs to no

  • Is there a multiplatform framework for developing iPhone / Android applications? 2008-08-27

    I am interested in writing applications for the iPhone and the Android platform. I was hoping to find a middleware / framework that abstracted away some of the differences in the APIs and allow me to specify the target platform at build time. Is ther

  • Updating Android Tab Icons 2008-08-31

    I have an activity which has a TabHost containing a set of TabSpecs each with a listview containing the items to be displayed by the tab. When each TabSpec is created, I set an icon to be displayed in the tab header. The TabSpecs are created in this

  • Moving to Android from J2ME 2008-09-15

    Coming from J2ME programming are there any similarities that would make it easy to adapt to Android API. Or is Android API completely different from the J2ME way of programming mobile apps. --------------Solutions------------- Actually the Android AP

  • Is there a way to run Python on Android? 2008-09-19

    I like the Android platform. Actually, with some friends, we even participate in the ADC with the Spoxt project. But Java is not my favourite language at all. We are working on an S60 version and this platform has a nice Python API. Of course there i

  • How well does the Android Phone Emulator reflect the performance? 2008-09-19

    I've been playing around with OpenGL ES development on Android. OpenGL ES applications seem to run slowly in the Emulator on my development machine. Does this reflect likely performance of actual hardware? I'm concerned about spending too much time d

  • Getting started with Android 2008-09-27

    So, I'll be getting my T-Mobile G1 within a month or so, and I'm excited to start developing for it. Has anyone started using it yet? Is there a dev wiki or anything set up for it yet? --------------Solutions------------- Google's android groups This

  • Porting Android's Java VM to the iPhone? 2008-09-29

    Does anyone know of any existing projects that aim to port Android's Java VM over to the iPhone? From what I understand, this wouldn't be too out of reach and would certainly make for some exciting developments. Edit: I should point out that I am awa

  • Does Android WebView need permissions for opening external URLs? 2008-10-13

    I was trying the following example, but with external URLs: http://android-developers.blogspot.com/2008/09/using-webviews.html The example shows how to load an HTML file from assets folder (file:// url) and display it in a WebView. But when I try it

  • Android API for detecting new media from inbuilt camera & mic 2008-10-23

    Is there any elegant way in the Android API for detecting new media when it is written to the device? I’m mainly interested in photos taken by the camera, video taken by the camera and audio recorded from the mic. My current thinking is to periodical

  • How to copy text programmatically in my Android app? 2008-10-26

    I'm building an Android app and I want to copy the text value of an EditText widget. It's possible for the user to press Menu+A then Menu+C to copy the value, but how would I do this programmatically? --------------Solutions------------- http://devel

  • Will JavaFX work on Android? 2008-10-27

    It would be a shame if it doesn't, because it will make for more attractive looking Android applications. --------------Solutions------------- Not right now, and it would be a nontrivial task to make it work. Android doesn't have all the libraries th

  • How do I find the DNS servers in Android from a Java program? 2008-10-30

    The java.net.InetAddress.GetByName(String host) method can only return A records so to lookup other record types I need to be able to send DNS queries using the dnsjava library. However that normally relies on being able to parse /etc/resolv.conf or

  • Android: Access child views from a ListView 2008-11-02

    I need to find out the pixel position of one element in a list that's been displayed using a ListView. It seems like I should get one of the TextViews and then use getTop(), but I can't figure out how to get a child view of a ListView. Update: The ch

  • Anyone have any impressions, hints, tutorials from developing for Google Android devices? 2008-11-10

    I have a T-Mobile G1 and I'm going to download the developer SDK and see if I can create a few simple apps for my phone. If you've done similar development, please answer below and tell me about your experience. Please share any links you found espec

  • How can I create icons for menu items in Android's ListView? 2008-11-13

    I am using a ListView to present the main screen of my application. The main screen is essentially a menu to get into the different sections of my application. Currently I have the ListView contents generatings programmatically in the onCreate method

  • How to call SOAP web service in Android 2008-11-18

    I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manu

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.091 (s). 11 q(s)