将值传递给服务、intentService 或 bindService?
Pass value to a Service, intentService or bindService?
我需要将 3 个浮点数传递给服务,最后服务需要将我送回 'true' 或 'false' 布尔值。
我读到了这两个但不知道我需要使用什么,
一个例子将不胜感激。
对于您的第一个问题:将 para 传递给意图服务
Using putExtra to pass values to intent service
,以及关于从 intent 服务向 activity 发回通知:
Using ResultReceiver in Android
或尝试在服务中使用回调接口并在 activity
上实现它
// on intent service
private onGetNotification notify=(onGetNotification)contextOfActivity;
public interface onGetNotification {
public setOnGetNotification(Boolean result);
}
// use when finish
public void endOfService(){
notify.setOnGetNotification(true);
}
希望有所帮助:)
我需要将 3 个浮点数传递给服务,最后服务需要将我送回 'true' 或 'false' 布尔值。
我读到了这两个但不知道我需要使用什么, 一个例子将不胜感激。
对于您的第一个问题:将 para 传递给意图服务
Using putExtra to pass values to intent service
,以及关于从 intent 服务向 activity 发回通知:
Using ResultReceiver in Android
或尝试在服务中使用回调接口并在 activity
上实现它// on intent service
private onGetNotification notify=(onGetNotification)contextOfActivity;
public interface onGetNotification {
public setOnGetNotification(Boolean result);
}
// use when finish
public void endOfService(){
notify.setOnGetNotification(true);
}
希望有所帮助:)