im trying to send string from service to activity - but i cant do this. I found a lot of examples - and nothing not work. Im using LocalBroadcastManger i add this part of code to mainactivity.
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Logger.e("RECEIVEEEEER!!!!!!!!!!!!!!!!");
}
};
and in onResume/onStart
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(
mMessageReceiver, new IntentFilter("myIntentKey"));
and in service i add this code
Intent intent = new Intent("myIntentKey");
intent.putExtra("key", "keyfromservice"); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent)
Service start from push notification . Main activity extends from "CordovaActivity". When code in service start - my broadcast receiver not get message(or call blabla) But if sendBroadcast run from main activity then this code work. Guys whats wrong ? Main problem that in service i have some calculation after i need send this new calculation to activity for showing on main UI. Please any can help me ? why i cant send String from Service to Activity.
UPD i have activity which extends from cordovaActivity( so my UI its webpage). I write js part which i call from java for update data on screen. When pushNotificaiton coming - i start service here
@Override
public void onMessageReceived(String from, Bundle data) {
for understanding logs in manifest for service i write
<service android:exported="false" android:name=".services.MyService" android:process=":myProcess">
so in logcat i can pick my process for monitoring.
SOLUTION when i remove
android:process=":myProcess"
broadcast start working as need. Thank to @Mike.M