Home | History | Annotate | Download | only in app
      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.Parcel;
     21 import android.os.Parcelable;
     22 
     23 /**
     24  * {@hide}
     25  */
     26 public class ResultInfo implements Parcelable {
     27     public final String mResultWho;
     28     public final int mRequestCode;
     29     public final int mResultCode;
     30     public final Intent mData;
     31 
     32     public ResultInfo(String resultWho, int requestCode, int resultCode,
     33             Intent data) {
     34         mResultWho = resultWho;
     35         mRequestCode = requestCode;
     36         mResultCode = resultCode;
     37         mData = data;
     38     }
     39 
     40     public String toString() {
     41         return "ResultInfo{who=" + mResultWho + ", request=" + mRequestCode
     42             + ", result=" + mResultCode + ", data=" + mData + "}";
     43     }
     44 
     45     public int describeContents() {
     46         return 0;
     47     }
     48 
     49     public void writeToParcel(Parcel out, int flags) {
     50         out.writeString(mResultWho);
     51         out.writeInt(mRequestCode);
     52         out.writeInt(mResultCode);
     53         if (mData != null) {
     54             out.writeInt(1);
     55             mData.writeToParcel(out, 0);
     56         } else {
     57             out.writeInt(0);
     58         }
     59     }
     60 
     61     public static final Parcelable.Creator<ResultInfo> CREATOR
     62             = new Parcelable.Creator<ResultInfo>() {
     63         public ResultInfo createFromParcel(Parcel in) {
     64             return new ResultInfo(in);
     65         }
     66 
     67         public ResultInfo[] newArray(int size) {
     68             return new ResultInfo[size];
     69         }
     70     };
     71 
     72     public ResultInfo(Parcel in) {
     73         mResultWho = in.readString();
     74         mRequestCode = in.readInt();
     75         mResultCode = in.readInt();
     76         if (in.readInt() != 0) {
     77             mData = Intent.CREATOR.createFromParcel(in);
     78         } else {
     79             mData = null;
     80         }
     81     }
     82 }
     83