Android BroadcastReceiver
<pre><code>public class MobileViaNetReceiver extends BroadcastReceiver {

    public void startDataService(Context context) {
        Log.i("MobileViaNetReceiver", "starting data service...");
        ComponentName comp = new ComponentName(context.getPackageName(), DataService.class.getName());
        ComponentName service = context.startService(new Intent().setComponent(comp));
        if (null == service)
        {
            Log.e("MobileViaNetReceiver", "Could not start data service " + comp.toString());
        } else {
            Log.i("MobileViaNetReceiver", "data service started");   
        }
    }

    public void startNotificationService(Context context) {
        Log.i("MobileViaNetReceiver", "starting notification service...");
        ComponentName comp = new ComponentName(context.getPackageName(), NotificationService.class.getName());
        ComponentName service = context.startService(new Intent().setComponent(comp));
        if (null == service)
        {
            Log.e("MobileViaNetReceiver", "Could not start notification service " + comp.toString());
        } else {
            Log.i("MobileViaNetReceiver", "notification service started");   
        }
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if ("android.intent.action.SHUTDOWN".equals(intent.getAction())) {
            // DO WHATEVER YOU NEED TO DO HERE
            Log.i("MobileViaNetReceiver", "Shut down - end user session");
            DbAdapter_User db = new DbAdapter_User(context);
            db.handleLogout();
            Log.i("MobileViaNetReceiver", "user logged out");
        } 

        if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
            Log.i("MobileViaNetReceiver", "device boot received - start services");
            startDataService(context);
            startNotificationService(context);
        }
        else {
            Log.i("MobileViaNetReceiver", "Received unexpected intent " + intent.toString());                        
        }
    }

}
</code></pre>

<p>This is my MobileViaNetReceiver.</p>

<pre><code>MobileViaNetReceiver rec = new MobileViaNetReceiver();
rec.startDataService(getBaseContext());
rec.startNotificationService(getBaseContext());
</code></pre>

<p>When I log in DataService is working. But NotificationService is not. They are defined exactly the same. What am I doing wrong?</p>
