I just want to write a "Hello World IntentService App". Unfortunately, I could not do that.
Problem:
MyIntentService.enqueueWork() method does not work.
enqueueWork() function of IntentService does not accept parameter MyIntentService.class
I searched in Google and YouTube a lot, but could not find anything helpful. Thank you very much in advance.
Sources:
https://developer.android.com/training/run-background-service/create-service
https://developer.android.com/training/run-background-service/send-request
https://developer.android.com/reference/android/support/v4/app/JobIntentService#enqueuework
Step 1: Create a new Android project
Step 2: Create a new Service File -> New -> Service -> Service (IntentService) (Just leave the name: MyIntentService)
// Step 3:
// Open: MyIntentService.java
// Just add a Toast in the method onHandleIntent() :
Toast.makeText(this, "Hello World!", Toast.LENGTH_SHORT).show();
// Step 4:
// Open: MainActivity.java.
// Add below code in an appropriate method:
Intent mServiceIntent = new Intent();
mServiceIntent.putExtra("name", "Harun");
int JOB_ID = 1000;
MyIntentService.enqueueWork(getApplicationContext(), MyIntentService.class, JOB_ID, mServiceIntent);
// Gives this error before run Error for enqueueWork -> "Cannot resolve method 'enqueueWork(android.content.Context, java.lang.Class, int, android.content.Intent)'"
// Step 5: Now, I run the application, and gives this error:
Compilation failed; see the compiler error output for details.
error: cannot find symbol method enqueueWork(Context, Class <- MyIntentService ->, int, Intent)
enqueueWork() function of IntentService does not accept parameter MyIntentService.class
Thanks a lot!