• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.location;
18 
19 import android.content.Context;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import java.util.Locale;
24 
25 /**
26  * This class contains extra parameters to pass to an IGeocodeProvider
27  * implementation from the Geocoder class.  Currently this contains the
28  * language, country and variant information from the Geocoder's locale
29  * as well as the Geocoder client's package name for geocoder server
30  * logging.  This information is kept in a separate class to allow for
31  * future expansion of the IGeocodeProvider interface.
32  *
33  * @hide
34  */
35 public class GeocoderParams implements Parcelable {
36     private Locale mLocale;
37     private String mPackageName;
38 
39     // used only for parcelling
GeocoderParams()40     private GeocoderParams() {
41     }
42 
43     /**
44      * This object is only constructed by the Geocoder class
45      *
46      * @hide
47      */
GeocoderParams(Context context, Locale locale)48     public GeocoderParams(Context context, Locale locale) {
49         mLocale = locale;
50         mPackageName = context.getPackageName();
51     }
52 
53     /**
54      * returns the Geocoder's locale
55      */
getLocale()56     public Locale getLocale() {
57         return mLocale;
58     }
59 
60     /**
61      * returns the package name of the Geocoder's client
62      */
getClientPackage()63     public String getClientPackage() {
64         return mPackageName;
65     }
66 
67     public static final Parcelable.Creator<GeocoderParams> CREATOR =
68         new Parcelable.Creator<GeocoderParams>() {
69         public GeocoderParams createFromParcel(Parcel in) {
70             GeocoderParams gp = new GeocoderParams();
71             String language = in.readString();
72             String country = in.readString();
73             String variant = in.readString();
74             gp.mLocale = new Locale(language, country, variant);
75             gp.mPackageName = in.readString();
76             return gp;
77         }
78 
79         public GeocoderParams[] newArray(int size) {
80             return new GeocoderParams[size];
81         }
82     };
83 
describeContents()84     public int describeContents() {
85         return 0;
86     }
87 
writeToParcel(Parcel parcel, int flags)88     public void writeToParcel(Parcel parcel, int flags) {
89         parcel.writeString(mLocale.getLanguage());
90         parcel.writeString(mLocale.getCountry());
91         parcel.writeString(mLocale.getVariant());
92         parcel.writeString(mPackageName);
93     }
94 }
95