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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:33:31+00:00 2026-06-11T20:33:31+00:00

My users are slowly being migrated to ICS (Android 4.0 and above) and since

  • 0

My users are slowly being migrated to ICS (Android 4.0 and above) and since then I can see new crash reports appearing … it looks like its my implementation of WakefulIntentService that triggers the following error:

java.lang.NullPointerException at
com.cousinHub.meteo.AppService.doWakefulWork(AppService.java:104) at
com.cousinHub.meteo.WakefulIntentService.onHandleIntent(WakefulIntentService.java:70)
at
android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
at android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:123) at
android.os.HandlerThread.run(HandlerThread.java:60)

line 70 looks the issue within onHandleIntent :

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;

abstract public class WakefulIntentService extends IntentService {
    abstract protected void doWakefulWork(Intent intent);

    public static final String LOCK_NAME_STATIC="com.commonsware.cwac.wakeful.WakefulIntentService";
    private static PowerManager.WakeLock lockStatic=null;

    public static void acquireStaticLock(Context context) {
        getLock(context).acquire();
    }

    synchronized private static PowerManager.WakeLock getLock(Context context) {
        if (lockStatic==null) {
            PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);

            lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOCK_NAME_STATIC);
            lockStatic.setReferenceCounted(true);
        }

        return(lockStatic);
    }

    public static void sendWakefulWork(Context ctxt, Intent i) {
        acquireStaticLock(ctxt);
        ctxt.startService(i);
    }

    @SuppressWarnings("unchecked")
    public static void sendWakefulWork(Context ctxt, Class clsService) {
        sendWakefulWork(ctxt, new Intent(ctxt, clsService));
    }

    public WakefulIntentService(String name) {
        super(name);
    }

    @Override
    public void onStart(Intent intent, int startId) {
        if (!getLock(this).isHeld()) {  // fail-safe for crash restart
            getLock(this).acquire();
        }

        super.onStart(intent, startId);
    }

    @Override
    final protected void onHandleIntent(Intent intent) {
        try {
            doWakefulWork(intent);
        }
        finally {
            getLock(this).release();
        }
    }
}

Any idea why this code would work fine on Gingerbread (Android < 4.0) and now breaks ??

try {
            doWakefulWork(intent);
        }

=> intent looks to be null for some reason ??

or maybe it’s the next block of code that triggers the NullPointer Exception :

finally {
            getLock(this).release();
        }
  • how would you solve this ?

this way maybe ?

if ((this!=null)&&(intent!=null)) {
            try {
                doWakefulWork(intent);
            }
            finally {
                getLock(this).release();
            }
        }
  • 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-11T20:33:33+00:00Added an answer on June 11, 2026 at 8:33 pm

    You will notice that your exception arises from:

    com.cousinHub.meteo.AppService.doWakefulWork(AppService.java:104)
    

    First, I do not write anything in the com.cousinHub.meteo package. Second, this would be in the implementation of a doWakefulWork() method, and the only ones of those I have published are merely samples. Third, you declined to publish your implementation of doWakefulWork() and point out which is line 104.

    I humbly suggest that you examine your AppService class, line 104, to determine where you are going wrong.

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

Sidebar

Related Questions

Users can use their Google, Facebook or Twitter account to login to a site
Users on my site can add nodes of a custom type (let's call it
Users on my site can post news items. But right now, it's all honor
I'm still pretty new to AJAX and javascript, but I'm getting there slowly. I
I have a content based, read-only iPhone app. Users can select favorite topics, which
As I am new to code igniter and MVC, I am slowly but surely
This query runs slowly: SELECT UserAccountNumber, balance, username FROM users JOIN balances ON users.UserAccountNumber=balances.UserAccountNumber
We migrate from WinForms to WPF... slowly =) No we use WPF User Controls
Users will be able to write some documents. Those documents will consists of chapters
Users have subscriptions to feeds but when I change (as suggested elsewhere on stackO)

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.