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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:05:50+00:00 2026-06-07T13:05:50+00:00

I am calling a service class from broadcastReciever My Class is As:- InsertIntoDB objinsert;

  • 0

I am calling a service class from broadcastReciever My Class is As:-

InsertIntoDB objinsert;
ArrayList<ContactClass> resultList;
ContactClass mContactClass =null;

public ScheduleService() {

     super("B'Day Checker Service");


}

@Override
protected void onHandleIntent(Intent intent)
  { 
    objinsert = new InsertIntoDB(this);
    Log.d("MyService", "About to execute MyTask");
    new MyTask().execute();

     }

private class MyTask extends AsyncTask<Void, Void, ArrayList<ContactClass>> 
   {

    @Override
    protected void onPreExecute() {

        super.onPreExecute();
         mContactClass = new ContactClass();
         resultList= new ArrayList<ContactClass>();
    }

    @Override
    protected ArrayList<ContactClass> doInBackground(Void... arg0)
    {
        List<ContactClass> contacts = objinsert.getAllContacts();
        for (ContactClass cn : contacts)
        {
            String mdob =  cn.getDob();
            long output = dateCompare(mdob);
            if(output==0)
            {
                mContactClass.setId(cn.getId());
                mContactClass.setName(cn.getName());
                mContactClass.setDob(cn.getDob());
                resultList.add(mContactClass);
            }

              Log.d("Name: ",""+resultList.size());
        }
        return resultList;
    }

    @Override
    protected void onPostExecute(ArrayList<ContactClass> result) {

        super.onPostExecute(result);
        System.out.println("posttttt");
        int length=0;
        if(result!=null)
        {
         length = result.size();
        }
        if(length!=0)
        {
            for(int mindex =0;mindex<length;mindex++)
            {
                String date = result.get(mindex).getDob();
                String[] arrdob =date.split("/");
                Calendar cal = Calendar.getInstance();
                cal.setTimeInMillis(System.currentTimeMillis());
                cal.clear();
                cal.set(Integer.parseInt(arrdob[2]), Integer.parseInt(arrdob[1])-1,Integer.parseInt(arrdob[0]),14,17);

                AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
                 Intent intent = new Intent(ScheduleService.this, BirthDayReciever.class);
                 PendingIntent pendingIntent = PendingIntent.getBroadcast(ScheduleService.this, 0, intent, 0);
                 //cal.add(Calendar.SECOND, 5);
                 alarmMgr.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
            }
        }


    }



}


public long dateCompare(String date)
 {
    System.out.println("date---"+date);
    String geivendate[] = date.split("/");
    int Day= Integer.parseInt(geivendate[0]);
    int Month= Integer.parseInt(geivendate[1]);
    int Year= Integer.parseInt(geivendate[2]);

    Date currentdate = new Date();
    Calendar calUpdated = Calendar.getInstance();
    calUpdated.set(Year, Month-1, Day);

    long updateDateMilliSec = calUpdated.getTimeInMillis();
    long diff = currentdate.getTime() - calUpdated.getTimeInMillis();
    long diffDays = (diff / (1000 * 60 * 60 * 24));

    return diffDays;
 }

But It is Not Working doinBackground method is running after that an exception in logcat not application crash only in logcat is as:-

07-11 14:16:34.444: W/MessageQueue(942): Handler{44f6ad40} sending message to a Handler on a dead thread
07-11 14:16:34.444: W/MessageQueue(942): java.lang.RuntimeException: Handler{44f6ad40} sending message to a Handler on a dead thread
07-11 14:16:34.444: W/MessageQueue(942):    at android.os.MessageQueue.enqueueMessage(MessageQueue.java:179)
07-11 14:16:34.444: W/MessageQueue(942):    at android.os.Handler.sendMessageAtTime(Handler.java:457)
07-11 14:16:34.444: W/MessageQueue(942):    at          android.os.Handler.sendMessageDelayed(Handler.java:430)
07-11 14:16:34.444: W/MessageQueue(942):    at android.os.Handler.sendMessage(Handler.java:367)
07-11 14:16:34.444: W/MessageQueue(942):    at android.os.Message.sendToTarget(Message.java:348)
07-11 14:16:34.444: W/MessageQueue(942):    at android.os.AsyncTask$3.done(AsyncTask.java:214)
07-11 14:16:34.444: W/MessageQueue(942):    at java.util.concurrent.FutureTask$Sync.innerSet(FutureTask.java:252)
07-11 14:16:34.444: W/MessageQueue(942):    at java.util.concurrent.FutureTask.set(FutureTask.java:112)
07-11 14:16:34.444: W/MessageQueue(942):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:310)
07-11 14:16:34.444: W/MessageQueue(942):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-11 14:16:34.444: W/MessageQueue(942):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-11 14:16:34.444: W/MessageQueue(942):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-11 14:16:34.444: W/MessageQueue(942):    at java.lang.Thread.run(Thread.java:1096)

anyone suggest me where I am wrong thanks in extra….

  • 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-07T13:05:52+00:00Added an answer on June 7, 2026 at 1:05 pm

    I would suggest you to set alarm manager in a simple method,

    You dont need asyncTask for this purpose.
    below error says Thread is already dead, and some thing trying to send a message to handler in a dead thread.

    07-11 14:16:34.444: W/MessageQueue(942): Handler{44f6ad40} sending message to a Handler on a dead thread
              07-11 14:16:34.444: W/MessageQueue(942): java.lang.RuntimeException: Handler{44f6ad40} sending message to a Handler on a dead thread
    

    below link can give you some hint over this issue

    link

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

Sidebar

Related Questions

----------Class library file where i am calling WCF service------------- public class AllEmployeeViewModel { //
I have some problem with calling web service from flex. I have service with
Hello I have next function, what always return null as result, but service calling
I'm calling a web service from a console app - all in C# on
I have service with thread, From activity I am calling start service(from Activity::onDestroy()) and
I'm having problems calling a class function from my Widget as the result of
I have the following class (which is a JPA entity listener): @Service public class
I have a problem when calling a method from an external web service. The
im calling an actionscript class from my main mxml file. the actionscript class is
I want to inherit from a class which is located in a WCF Service.

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.