android - Starting and dismissing progressDialog from Service -
i have android application structure:
activity a,b,c, service s
when i'm on activity c open dialog in insert data. when ok button pressed, 2 operation:
- start service
- call intent starting activity (that main activity)
until service not provide necessary data actvity show inconsistent data , button disabled. until data not available, progress bar displayed.
so problem need start progressdialog dialog in activity c, need "link" dialog main activity (a) , dismiss progressdialog service.
how can perform task?
use localbroadcastmanager register in onstart , unregister in onpause in activitys want communicate service. in service compute expensive operation , sendbroadcast when job finishes. in activity c show progress dialog. when job finishes dismiss progress dialog , start activity a. or can check flag in oncreate in activity know if need show progressdialog , when service sendbroadcast dismiss progressdialog.
Comments
Post a Comment