Android wearableListenerService从activity调用方法

时间:2015-10-10 17:29:51

标签: android android-activity wear-os public

有没有办法从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.
   }
   ...
}

1 个答案:

答案 0 :(得分:0)

您可以Broadcast举办活动并在BroadcastReceiver注册Activity。如果当前活动是屏幕上的当前活动,您还可以在活动中连接GooglePlayClient并让它处理onMessageReceived事件