1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.app; 18 19 import android.content.Intent; 20 import android.os.IBinder; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 import android.os.Bundle; 24 25 import java.util.Map; 26 27 /** 28 * {@hide} 29 */ 30 public class ResultInfo implements Parcelable { 31 public final String mResultWho; 32 public final int mRequestCode; 33 public final int mResultCode; 34 public final Intent mData; 35 36 public ResultInfo(String resultWho, int requestCode, int resultCode, 37 Intent data) { 38 mResultWho = resultWho; 39 mRequestCode = requestCode; 40 mResultCode = resultCode; 41 mData = data; 42 } 43 44 public String toString() { 45 return "ResultInfo{who=" + mResultWho + ", request=" + mRequestCode 46 + ", result=" + mResultCode + ", data=" + mData + "}"; 47 } 48 49 public int describeContents() { 50 return 0; 51 } 52 53 public void writeToParcel(Parcel out, int flags) { 54 out.writeString(mResultWho); 55 out.writeInt(mRequestCode); 56 out.writeInt(mResultCode); 57 if (mData != null) { 58 out.writeInt(1); 59 mData.writeToParcel(out, 0); 60 } else { 61 out.writeInt(0); 62 } 63 } 64 65 public static final Parcelable.Creator<ResultInfo> CREATOR 66 = new Parcelable.Creator<ResultInfo>() { 67 public ResultInfo createFromParcel(Parcel in) { 68 return new ResultInfo(in); 69 } 70 71 public ResultInfo[] newArray(int size) { 72 return new ResultInfo[size]; 73 } 74 }; 75 76 public ResultInfo(Parcel in) { 77 mResultWho = in.readString(); 78 mRequestCode = in.readInt(); 79 mResultCode = in.readInt(); 80 if (in.readInt() != 0) { 81 mData = Intent.CREATOR.createFromParcel(in); 82 } else { 83 mData = null; 84 } 85 } 86 } 87