For example, I use the activity object mainactivity the context acquired sharedpreferences object and putString (context, "demo", "aaaa");
Then get sharedpreferences object with the service object myservice of context, getString (context, "demo", ""); Thus obtained is "aaaa", is correct, but I then modify the key to "demo" values mainactivity, the change "bbbb" Then again get in myservice the "demo" of the value of the key bit, but still "aaaa", meaning that data is not synchronized, but I used RE Manager to view the configuration file, the key is "demo" of the values have changed "bbbb" a .... After seeking help, and I modified the configuration file service, activity go read, or the original data, but with the RE Manager to view, modify indeed ah, the data did not sync it?
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: Is not no call to commit Reply: called, feeling activity and service operations are not the same configuration files, and I in service in the configuration file for writing, but I went to see the RE configuration file, find service did not successfully modified. However, activity modification can be successful.
I finally used the intent parameter passing, passing parameters to obtain the onstart method inside. Reply: commit there is a return value, you can look at. true success is modified, false failure. Reply: I have encountered this problem before, back into sync with the data of the handler. If the landlord insists on using the service, it can be more convenient with BroadCast match, when activity in the data changes, with the broadcast distributed services. Reply:
Do you mean to let service also inherited BroadcastReceiver onReceive then update the data in it, a good idea Reply: There is such a thing? Been using sharedpreferences, temporarily not encountered this situation the landlord. Reply:
This is a method, but may cause a delay broadcast. Reply:
I have encountered this problem before, back into sync with the data of the handler. If the landlord insists on using the service, it can be more convenient with BroadCast match, when activity in the data changes, with the broadcast distributed services.
Do you mean to let service also inherited BroadcastReceiver onReceive then update the data in it, a good idea
This is a method, but may cause a delay broadcast.
java does not support multiple inheritance. . . Reply:
I have encountered this problem before, back into sync with the data of the handler. If the landlord insists on using the service, it can be more convenient with BroadCast match, when activity in the data changes, with the broadcast distributed services.
Do you mean to let service also inherited BroadcastReceiver onReceive then update the data in it, a good idea
This is a method, but may cause a delay broadcast.
I have encountered this problem before, back into sync with the data of the handler. If the landlord insists on using the service, it can be more convenient with BroadCast match, when activity in the data changes, with the broadcast distributed services.
Do you mean to let service also inherited BroadcastReceiver onReceive then update the data in it, a good idea
This is a method, but may cause a delay broadcast.
java does not support multiple inheritance. . .
I have encountered this problem before, back into sync with the data of the handler. If the landlord insists on using the service, it can be more convenient with BroadCast match, when activity in the data changes, with the broadcast distributed services.
Do you mean to let service also inherited BroadcastReceiver onReceive then update the data in it, a good idea
This is a method, but may cause a delay broadcast.
java does not support multiple inheritance. . .
Inheritance is the service did not say where sendBroadcast, and then process the data in onReceive () in Reply: I have encountered this problem before, but a little research found that, getSharedPreferences used when the mode is MODE_PRIVATE, this mode does not support data synchronization between the activity with the service. The mode changed MODE_MULTI_PROCESS, the activity can be resolved directly modify share data, service can be directly synchronized. I do not know the landlord is not able to solve the problem Reply:
I also encountered this problem before, but a little research found that, getSharedPreferences used when the mode is MODE_PRIVATE, which kind of mode does not support data synchronization between the activity with the service. The mode changed MODE_MULTI_PROCESS, the activity can be resolved directly modify share data, service can be directly synchronized. I do not know the landlord is not able to solve the problem
No comments:
Post a Comment