您可以使用 ResultReceiver 来完成。我制作了一个应用程序,我将大型视频上传到服务器并使用了这样的东西:
public class MyResultReceiver extends ResultReceiver {
public final String TAG = getClass().getSimpleName();
private Receiver mReceiver;
public TmResultReceiver(Handler handler) {
super(handler);
// TODO Auto-generated constructor stub
}
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
// TODO Auto-generated method stub
Log.d("MyResultReceiver", "onReceiveResult");
if( mReceiver != null ){
mReceiver.onReceiveResult(resultCode, resultData);
}
}
public void setReceiver(Receiver receiver) {
//Log.d("MyResultReceiver", "setReceiver");
mReceiver = receiver;
}
public interface Receiver {
public void onReceiveResult(int resultCode, Bundle resultData);
}
}