android - Accessing Context -


i have broadcast receiver used receive broadcast pending intent using api requestlocationupdates.
context receive in onreceive(..) method has ui elements , objects of calling activity in (which see using watch window).
there way/method access these ui elements or objects contained within context?

here's snippet:

mainactivity {    //initialize pending intent             locationmanagerobject.requestlocationupdates(provider,0,0,pendingintent);     //registering broadcast reciver }   broadcastreciverclass {     onreceive(context context, intent intent) {         /*i want gain access objects of main activity. can          see them in context if use watch window monitor           context object. want find way able access them , use them*/     }  } 

why want gain access objects on main activity? i'm asking because i'm wondering if there's better architectural decision made. activities intentionally modular.

if you're looking update ui components in mainactivity when receiving broadcast, following:

  • broadcast message broadcastreciverclass , register receiver in mainactivity update accordingly.

  • change data in shared/singleton class when receiving message , make appropriate ui change in mainactivity in onresume() method.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -