Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

NPE in @EIntentService.onHandleIntent #1499

@simonz

Description

@simonz

NullPointerException was often occurred in @EIntentService.onHandleIntent
This is the generated @EIntentService code,

    @Override
    public void onHandleIntent(Intent intent) {
        MyIntentService_.super.onHandleIntent(intent);
        String action = intent.getAction();
        if (ACTION_EXECUTE.equals(action)) {
            // ....
        }   

sometimes intent gets null, so intent.getAction() makes NPE.
And I could find the documentation from http://developer.android.com/reference/android/app/IntentService.html#onStartCommand(android.content.Intent,%20int,%20int)

The Intent supplied to startService(Intent), as given. This may be null if the service is being restarted after its process has gone away, and it had previously returned anything except START_STICKY_COMPATIBILITY.

I think it is safe to check whether intent is null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions