如何更新Windows服务对话框中的@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnResult = (Button) findViewById(R.id.btnResult);
btnResult.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String val = "hello";
Message msg = Message.obtain(null, DeviceService.TO_UPPERCASE);
msg.replyTo = new Messenger(new ResponseHandler());
Bundle b = new Bundle();
b.putString("data", val);
msg.setData(b);
try {
mService.send(msg);
} catch (RemoteException e) {
e.printStackTrace();
}
}
});
Button btnStart = (Button) findViewById(R.id.btn_start_keypad_listener);
btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Message msg = Message.obtain(null, DeviceService.MSG_START_REST);
msg.replyTo = new Messenger(new ResponseHandler());
try {
mService.send(msg);
} catch (RemoteException e) {
e.printStackTrace();
}
}
});
}
列?
答案 0 :(得分:0)
我讨厌回答我自己的问题,但没有人回答这个问题......
不幸的是,事实证明,您无法直接更新Status
字段,因为它是READ-ONLY。但是,您可以暂停服务,如下所示:
var serviceController = new ServiceController(ServiceName);
serviceController.Pause(); // Pauses the service
serviceController.Refresh(); // Refreshes the Dialog UI with the new Status
这很不幸,因为没有“真实”的方式来显示服务的FAULT-STATE。