- Where Developers Learn, Share, & Build Careers
I have an asyncTask that starts on boot (called by a service) in some cases i I would like to send a notification to get started. My problem comes when I try to make a call:
Notification Manager No Manager = (Notification Manager) getSystemService (ns); Where Eclipse shows me an error because AsyncTask is not foundSystem System Service
Because the getSystemService reference class is a method. See it.
Before calling the function, create a reference variable in your AsyncTask. Then start it in your constructor, that is,
context reference; Public MyAsyncTask {context = contextin;} Then use this reference variable to call your function:
NotificationManager notManager = (NotificationManager) reference .getSystemService (ns); When you are performing asyncTask, do not forget to input your reference:
MyAsyncTask mytask = New MyAsyncTask (getApplicationContext ()) ; Mytask.execute (); I also felt that an IntentService would be more suitable for your needs.
Comments
Post a Comment