Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Runtime Exception: "Please specify a service class to monitor. Use #createIntent as helper." #299

Closed
kaivnlp opened this issue Apr 26, 2014 · 2 comments

Comments

@kaivnlp
Copy link

kaivnlp commented Apr 26, 2014

I am getting this exception when i am trying to create a notification service extending
"com.octo.android.robospice.notification.SpiceNotificationService"
Error occurs when one of the fragments tries to start the service.Looked at the code and error appears obvious , Can you please confirm if this is the issue.

Check on "spiceService" variable is before it is assigned a value..

@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" })
    @Override
    public final void onStart(final Intent intent, final int startId) {
        super.onStart(intent, startId);
        notificationId = intent.getIntExtra(BUNDLE_KEY_NOTIFICATION_ID, DEFAULT_ROBOSPICE_NOTIFICATION_ID);
        requestClass = (Class<?>) intent.getSerializableExtra(BUNDLE_KEY_REQUEST_CLASS);
        if (spiceServiceClass == null) {
            throw new RuntimeException("Please specify a service class to monitor. Use #createIntent as helper.");
        }
        requestCacheKey = intent.getStringExtra(BUNDLE_KEY_REQUEST_CACHE_KEY);
        spiceServiceClass = (Class<? extends SpiceService>) intent.getSerializableExtra(BUNDLE_KEY_SERVICE_CLASS);
        foreground = intent.getBooleanExtra(BUNDLE_KEY_FOREGROUND, true);

        spiceManager = new SpiceManager(spiceServiceClass);
        notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        spiceManager.start(this);
        spiceManager.addListenerIfPending(requestClass, requestCacheKey, new NotificationRequestListener());

        if (foreground) {
            startForeground(notificationId, onCreateForegroundNotification());
        }
    }
@stephanenicolas
Copy link
Owner

Gloops. This looks terrible ;)

Can you confirm that moving the assignment up corrects the bug ? Did you try it yourself ?

@stephanenicolas stephanenicolas added this to the 1.4.13 milestone Jun 10, 2014
stephanenicolas added a commit that referenced this issue Jun 11, 2014
@stephanenicolas
Copy link
Owner

Thx for submitting this bug, it has been fixed and will be released in 1.4.13. If you wanna try our snapshot, that would help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants