Reputation: 422
I would like to create a Runnable which I can start in an Activity and still access in another Activity to retrieve data from it.
Is it something you would not advise ?
Another option would be to pass a bitmap with an intent and do everything on the same activity but this activity will often open another Activity for result so will that be a problem for the background Runnable ?
Thanks for your help, be sure to ask for clarifications if needed !
Upvotes: 0
Views: 60
Reputation: 18276
A new activity should only have parcelables as arguments, so a Runnable can not fit.
Static access is a bad pratice.
The solution is to have a Service where you can start/bind from one activity and bind from the second activities.
Starting another activity is not a problem for the Runnable, if it has it owns thread, but get advised that when the task finish you CANT touch your views while the activity is still in onStop state, resulting in an Exception.
Upvotes: 1