Whenever you Activity will need to update that string, it will save it as preference and on the onReceive method of your broadcastreceiver, you just get it back from the preference.
– IZI_Shadow_IZI Jul 28 at 1:18 No it can't but it can be a Set. See the method getStringSet. The difference is just that you can not get any duplicate string (while a List allows you to have duplicate) – ccheneson Jul 28 at 6:49 only works for 3.0 – IZI_Shadow_IZI Jul 28 at 12:33 another solution would be that after the user hits submit, send a broadcast to your broadcast receiver and add the new string in the intent.
In your broadcastreceiver, you just check if the key you use to set the string in the intent is present. If it is, then you can add it to an array that you would have to set on the broadcastreceiver start. – ccheneson Jul 28 at 13:29 I was able to update the broadcast reciever by calling sendBroadcast from the actvity with a custom intent.
THANKS! – IZI_Shadow_IZI Jul 28 at 15:08.
I don't think you can. If you look at the Receiver Lifecycle documentation you'll see that the lifecycle is limited to onReceive. If the receiver's lifecycle is long enough for the user to interact with it, I'd simply use the BroadcastReceiver to start a service.
The service could do two things: start a background thread to perform your long-running task register a (different) BroadcastRecevier with an IntentFilter for updates to the string (as updated by the User in an Activity). When the Service receives the Intent it will update the string value. Note you'll have to synchronization between the service and the background thread (left as an exercise to the interested reader).
Then have your Activity code fire an Intent whenever the user modifies the value in question. The nice thing about this solution is if the service isn't running then the Intent gets dropped on the floor and you don't have to start the Service at all. If the Service is running, then your update occurs.
If the receiver's lifecycle is long enough for the user to interact with it, I'd simply use the BroadcastReceiver to start a service. Register a (different) BroadcastRecevier with an IntentFilter for updates to the string (as updated by the User in an Activity). When the Service receives the Intent it will update the string value.
Note you'll have to synchronization between the service and the background thread (left as an exercise to the interested reader). Then have your Activity code fire an Intent whenever the user modifies the value in question. The nice thing about this solution is if the service isn't running then the Intent gets dropped on the floor and you don't have to start the Service at all.
If the Service is running, then your update occurs.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.