What is the correct way to send messages from my IntentService back to Activity?

I have an application in which the main action fires AlarmReceiver, which calls an IntentService, which runs in the background and does everything. I don’t know how to correctly check the actions of the IntentService and present some feedback to the end user in the visible activity in which they are in the current state of the IntentService. In my ideal world, there might be an icon on the screen that I can customize to notify the user of what's happening with the IntentService. I don’t need the user to be able to * do anything, just get feedback.

All tips are welcome.

+3
source share
1 answer

Android API , - .

, , .

:

Intent i = new Intent("your.action");
sendBroadcast(i);

, :

private BroadcastReceiver myReceiver = new BroadcastReceiver() {        
    @Override
    public void onReceive(Context context, Intent intent) {
        //
    }
};

...

registerReceiver(myReceiver, new IntentFilter("your.action"));
+4

All Articles