赞
踩
(1)使用Activity系统函数传递数据
(2)使用自定义接口函数传递数据
(3)使用广播消息传递数据
示例代码如下:
publicstatic void registerApiListener(Context context, BroadcastReceiver receiver,String actionId) {
LocalBroadcastManager.getInstance(context).registerReceiver(receiver,new IntentFilter(actionId));
}
privatevoid sendResponseData(Response<?> response) {
Intent intent = new Intent(API_ACTION_RAW_RESPONSE);
intent.putExtra(API_RESPONSE_OBJECT,response);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
@Override
public void onReceive(Context context,Intent intent) {
Serializable dataObject =
intent.getExtras().getSerializable(ApiService.API_RESPONSE_OBJECT);
Object responseObject =
((Response<Object>)dataObject).getRe
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。