Issue
How does a smartwatch monitor incoming call status, ongoing calls, and call endings?
Solution
public void onStart(Intent intent) {
super.onStart(intent);
super.setUIContent(ResourceTable.Layout_ability_main);
LogUtil.error(TAG, "---onStart:---" );
context = this;
initCallManager();
callListener();
}
private void initCallManager() {
mDistributedCallManager = DistributedCallManager.getInstance(context);
mWearCallStateObserver = new WearCallStateObserver();
}
private void callListener() {
LogUtil.error(TAG, "callListener:" + mDistributedCallManager);
if (this.mDistributedCallManager != null) {
LogUtil.error(this.TAG, "CallStateObserver");
this.mDistributedCallManager.addObserver(mWearCallStateObserver, CallStateObserver.OBSERVE_MASK_CALL_STATE);
}
}
private class WearCallStateObserver extends CallStateObserver {
public WearCallStateObserver() throws IllegalArgumentException {
super();
}
public void onCallStateUpdated(int state, String number) {
super.onCallStateUpdated(state, number);
LogUtil.error(TAG, "onCallStateUpdated:" + state);
if (state == CALL_STATE_OFFHOOK) {
CallStateObserver.CALL_STATE_RINGING(Number 1); // Call status
CallStateObserver.CALL_STATE_OFFHOOK(Number 2); // In a call
CallStateObserver.CALL_STATE_IDLE (Number 0); // Hang up
}
}
}
Top comments (0)