有没有办法从wearableListenerService调用活动的非静态方法? (wearableListenerService无法绑定服务。因为onBind()方法是最终的。)
简化示例:
Service.class:
public class MyService extends WearableListenerService {
@Override
public void onMessageReceived(MessageEvent messageEvent){
myActivityMethod();
}
...
}
Activity.class:
public class MyActivity extends Activity {
public void myActivityMethod(){
//do sth.
}
...
}
答案 0 :(得分:0)
您可以Broadcast
举办活动并在BroadcastReceiver
注册Activity
。如果当前活动是屏幕上的当前活动,您还可以在活动中连接GooglePlayClient
并让它处理onMessageReceived
事件