I'm still new to Android and working my way through a lesson which is trying to teach me how to use an Intent Service to do work on a non-UI thread. However, when I call the Intent Service, nothing seems to happen.
Here is the Intent Service call from MainActivity
startIntentService = (Button) findViewById(R.id.button4);
startIntentService.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick (View v){
Intent delayIntent = new Intent(getApplicationContext(),
DelayIntentService.class);
startService(delayIntent);
Here is the DelayIntentService code
public class DelayIntentService extends IntentService {
public static final String ACTION_DELAY =
"hinz.don.hour5.action.DELAY";
public static final String EXTRA_MESSAGE =
"hinz.don.hour5.extra.MESSAGE";
public DelayIntentService() {
super("DelayIntentService");
}
@Override
protected void onHandleIntent (Intent intent){
SystemClock.sleep(5000);
Intent broadcastIntent = new Intent ();
broadcastIntent.setAction(ACTION_DELAY);
broadcastIntent.putExtra(EXTRA_MESSAGE, "UPDATED USING INTENT SERVICE");
sendBroadcast(broadcastIntent);
and here is the service declaration from the Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hinz.don.hour5">
<service android:name="hinz.don.Hour5.DelayIntentService"></service>
I've placed a debug break on the Intent Service code but it never executes it