开发者

Passing data from a service to a non activity class/object

开发者 https://www.devze.com 2022-12-18 04:06 出处:网络
I currently have a service running in my Android application that makes a wifi scan at a set interval and returns the results.

I currently have a service running in my Android application that makes a wifi scan at a set interval and returns the results.

I was then passing the data using an aidl interface and to do this I had to bind the service to my Activity I was passing the data to.

However the design has changed and I now need to be able to send the data that the Service returns to just a normal class that does not extend an Activity.

So I want to pass the data from the service just to another class that doesn't extend Activity and then be able to use that data in a method of that class.

So I was wondering how I would go about this if it is possible?

EDIT:

Actually is this even the correct way to implement the following:

I have an application that will have no User Interface (not exactly none altogether but VERY minimal).

I want it to scan for Wifi access points at regular intervals, check the connected state of Wifi and check the connected level of the currently connected access point.

It also listens for the OUT_GOING_CALL broadcast and traps the call if connected to wifi and then pops up a dialog that tells the user the call has been blocked and offers the user cheaper options than Gsm if there are any.

I currently use the Broadcasts to get the Scan Results and to get ch开发者_开发问答anges in the connected Level of the wifi connection also.

However I had thought that moving these to a service of my own would be a good idea, however would I be better leaving them as Broadcast Recievers in Non Activtiy and Non Service classes and just make the main Engine of the application a service that turns on and off these broadcasts from there Classes (Objects) ?

0

精彩评论

暂无评论...
验证码 换一张
取 消