How do I publish an update to Dashclock when my ap

2019-01-27 06:01发布

I have added a location proximity later using Android's addProximityAlert method in the LocationManager class.

When the user's phone is a particular area, the LocationManager sends an Intent to my application's BroadcastReciver and here is the class that handles the intent:

public class ProximityTrigger extends BroadcastReceiver {

    @Override
    public void onReceive(Context ctxContext, Intent ittIntent) {            
        System.out.println(ittIntent.getIntExtra(WidgetService.KEY_STOP_IDENTIFIER, -1));               
    }

}

I'd like to use the DashClock API to show an update when this happens. DashClock has a publishUpdate method that can be used to show updates but I can only use this from my extension class that extends the DashClock class. This should be a possible somehow but I can't seem to figure out how. Any ideas on how I could accomplish this?

1条回答
Viruses.
2楼-- · 2019-01-27 06:13

Since the extension service must issue the publishUpdate call, your proximity trigger broadcast receiver should use something like a broadcast or an event bus to ask the extension to publish an update.

If the extension isn't initialized, meaning the user hasn't added it or DashClock isn't running, then nothing will happen, which is the expected and correct behavior. As soon as DashClock starts and your extension is added, onUpdateData will be called and you'll be able to publish your update.

For some ideas on the actual classes you can use, see below:

A full code snippet for global broadcasts can be found in issue 292 on the DashClock project page.

查看更多
登录 后发表回答