├── .gitignore
├── CONTRIB.md
├── HelloEndpointsProject
├── HelloEndpoints
│ ├── build.gradle
│ ├── libs
│ │ └── android-support-v4.jar
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── ic_launcher-web.png
│ │ ├── java
│ │ └── com
│ │ │ ├── appspot
│ │ │ └── your_app_id
│ │ │ │ └── helloworld
│ │ │ │ ├── Helloworld.java
│ │ │ │ ├── HelloworldRequest.java
│ │ │ │ ├── HelloworldRequestInitializer.java
│ │ │ │ ├── HelloworldScopes.java
│ │ │ │ └── model
│ │ │ │ ├── HelloGreeting.java
│ │ │ │ └── HelloGreetingCollection.java
│ │ │ └── google
│ │ │ └── devrel
│ │ │ └── samples
│ │ │ └── helloendpoints
│ │ │ ├── AppConstants.java
│ │ │ ├── Application.java
│ │ │ └── MainActivity.java
│ │ └── res
│ │ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── menu
│ │ └── main.xml
│ │ ├── values-sw600dp
│ │ └── dimens.xml
│ │ ├── values-sw720dp-land
│ │ └── dimens.xml
│ │ ├── values-v11
│ │ └── styles.xml
│ │ ├── values-v14
│ │ └── styles.xml
│ │ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | HelloEndpointsProject/.idea/**
2 | HelloEndpointsProject/.gradle/**
3 | HelloEndpointsProject/local.properties
4 | HelloEndpointsProject/HelloEndpoints/build/**
5 | HelloEndpointsProject/HelloEndpoints/src/main/gen/**
6 | *.iml
7 | pom.xml
8 | out/**
9 |
--------------------------------------------------------------------------------
/CONTRIB.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your sample apps and patches! Before we can take them, we have to jump a couple of legal hurdles.
6 |
7 | Please fill out either the individual or corporate Contributor License Agreement (CLA).
8 |
9 | * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html).
10 | * If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html).
11 |
12 | Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests.
13 |
14 | ## Contributing A Patch
15 |
16 | 1. Submit an issue describing your proposed change to the repo in question.
17 | 1. The repo owner will respond to your issue promptly.
18 | 1. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
19 | 1. Fork the desired repo, develop and test your code changes.
20 | 1. Ensure that your code adheres to the existing style in the sample to which you are contributing. Refer to the [Google Cloud Platform Samples Style Guide](https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the recommended coding standards for this organization.
21 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
22 | 1. Submit a pull request.
23 |
24 | ## Contributing A New Sample App
25 |
26 | 1. Submit an issue to the GoogleCloudPlatform/Template repo describing your proposed sample app.
27 | 1. The Template repo owner will respond to your enhancement issue promptly. Instructional value is the top priority when evaluating new app proposals for this collection of repos.
28 | 1. If your proposal is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
29 | 1. Create your own repo for your app following this naming convention:
30 | * {product}-{app-name}-{language}
31 | * products: appengine, compute, storage, bigquery, prediction, cloudsql
32 | * example: appengine-guestbook-python
33 | * For multi-product apps, concatenate the primary products, like this: compute-appengine-demo-suite-python.
34 | * For multi-language apps, concatenate the primary languages like this: appengine-sockets-python-java-go.
35 | 1. Clone the README.md, CONTRIB.md and LICENSE files from the GoogleCloudPlatform/Template repo.
36 | 1. Ensure that your code adheres to the existing style in the sample to which you are contributing. Refer to the [Google Cloud Platform Samples Style Guide](https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the recommended coding standards for this organization.
37 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
38 | 1. Submit a request to fork your repo in GoogleCloudPlatform organizationt via your proposal issue.
39 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 | dependencies {
6 | classpath 'com.android.tools.build:gradle:0.6.+'
7 | }
8 | }
9 |
10 | apply plugin: 'android'
11 |
12 | repositories {
13 | mavenCentral()
14 | maven {
15 | url 'http://google-api-client-libraries.appspot.com/mavenrepo'
16 | }
17 | }
18 |
19 | dependencies {
20 | compile 'com.android.support:support-v4:13.0.+'
21 |
22 | // BEGIN Google APIs
23 |
24 | // Play Services will validate the application prior to allowing OAuth2 access.
25 | compile(group: 'com.google.android.gms', name: 'play-services', version: '3.2.25')
26 |
27 | // The following lines implement maven imports as defined at:
28 | // https://code.google.com/p/google-api-java-client/wiki/Setup
29 |
30 | // Add the Google API client library.
31 | compile(group: 'com.google.api-client', name: 'google-api-client', version: '1.17.0-rc') {
32 | // Exclude artifacts that the Android SDK/Runtime provides.
33 | exclude(group: 'xpp3', module: 'xpp3')
34 | exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
35 | exclude(group: 'junit', module: 'junit')
36 | exclude(group: 'com.google.android', module: 'android')
37 | }
38 |
39 | // Add the Android extensions for the Google API client library.
40 | // This will automatically include play services as long as you have download that library
41 | // from the Android SDK manager.
42 | // Add the Android extensions for the Google API client library.
43 | compile(group: 'com.google.api-client', name: 'google-api-client-android',
44 | version: '1.17.0-rc') {
45 | // Exclude play services. Explicitly include it above after you have installed Play
46 | // services from the Android SDK manager.
47 | exclude(group: 'com.google.android.google-play-services', module: 'google-play-services')
48 | }
49 |
50 | // END Google APIs
51 |
52 | // The following client libraries make HTTP/JSON on Android easier.
53 |
54 | // Android extensions for Google HTTP Client.
55 | compile(group: 'com.google.http-client', name: 'google-http-client-android',
56 | version: '1.17.0-rc') {
57 | exclude(group: 'com.google.android', module: 'android')
58 | }
59 |
60 | // This is used by the Google HTTP client library.
61 | compile(group: 'com.google.guava', name: 'guava', version: '14.0.+')
62 |
63 | }
64 |
65 | android {
66 | compileSdkVersion 19
67 | buildToolsVersion "19.0.0"
68 |
69 | defaultConfig {
70 | minSdkVersion 8
71 | targetSdkVersion 19
72 | }
73 | }
74 |
75 |
76 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/appengine-endpoints-helloendpoints-android/e1c51eb7a7403272f3ef24cbfff887729c4edb22/HelloEndpointsProject/HelloEndpoints/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/appengine-endpoints-helloendpoints-android/e1c51eb7a7403272f3ef24cbfff887729c4edb22/HelloEndpointsProject/HelloEndpoints/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/appspot/your_app_id/helloworld/Helloworld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
3 | * in compliance with the License. You may obtain a copy of the License at
4 | *
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | *
7 | * Unless required by applicable law or agreed to in writing, software distributed under the License
8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 | * or implied. See the License for the specific language governing permissions and limitations under
10 | * the License.
11 | */
12 | /*
13 | * This code was generated by https://code.google.com/p/google-apis-client-generator/
14 | * (build: 2013-09-16 16:01:30 UTC)
15 | * on 2013-09-30 at 22:19:22 UTC
16 | * Modify at your own risk.
17 | */
18 |
19 | package com.appspot.your_app_id.helloworld;
20 |
21 | /**
22 | * Service definition for Helloworld (v1).
23 | *
24 | *
25 | * This is an API
26 | *
27 | *
28 | *
29 | * For more information about this service, see the
30 | * API Documentation
31 | *
32 | *
33 | *
34 | * This service uses {@link HelloworldRequestInitializer} to initialize global parameters via its
35 | * {@link Builder}.
36 | *
37 | *
38 | * @since 1.3
39 | * @author Google, Inc.
40 | */
41 | @SuppressWarnings("javadoc")
42 | public class Helloworld extends com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient {
43 |
44 | // Note: Leave this static initializer at the top of the file.
45 | static {
46 | com.google.api.client.util.Preconditions.checkState(
47 | com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION == 1 &&
48 | com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION >= 15,
49 | "You are currently running with version %s of google-api-client. " +
50 | "You need at least version 1.15 of google-api-client to run version " +
51 | "1.17.0-rc of the helloworld library.", com.google.api.client.googleapis.GoogleUtils.VERSION);
52 | }
53 |
54 | /**
55 | * The default encoded root URL of the service. This is determined when the library is generated
56 | * and normally should not be changed.
57 | *
58 | * @since 1.7
59 | */
60 | public static final String DEFAULT_ROOT_URL = "https://your-app-id.appspot.com/_ah/api/";
61 |
62 | /**
63 | * The default encoded service path of the service. This is determined when the library is
64 | * generated and normally should not be changed.
65 | *
66 | * @since 1.7
67 | */
68 | public static final String DEFAULT_SERVICE_PATH = "helloworld/v1/";
69 |
70 | /**
71 | * The default encoded base URL of the service. This is determined when the library is generated
72 | * and normally should not be changed.
73 | */
74 | public static final String DEFAULT_BASE_URL = DEFAULT_ROOT_URL + DEFAULT_SERVICE_PATH;
75 |
76 | /**
77 | * Constructor.
78 | *
79 | *
80 | * Use {@link Builder} if you need to specify any of the optional parameters.
81 | *
82 | *
83 | * @param transport HTTP transport, which should normally be:
84 | *
85 | *
Google App Engine:
86 | * {@code com.google.api.client.extensions.appengine.http.UrlFetchTransport}
87 | *
Android: {@code newCompatibleTransport} from
88 | * {@code com.google.api.client.extensions.android.http.AndroidHttp}
127 | *
128 | * @return the resource collection
129 | */
130 | public Greetings greetings() {
131 | return new Greetings();
132 | }
133 |
134 | /**
135 | * The "greetings" collection of methods.
136 | */
137 | public class Greetings {
138 |
139 | /**
140 | * Create a request for the method "greetings.authed".
141 | *
142 | * This request holds the parameters needed by the helloworld server. After setting any optional
143 | * parameters, call the {@link Authed#execute()} method to invoke the remote operation.
144 | *
145 | * @return the request
146 | */
147 | public Authed authed() throws java.io.IOException {
148 | Authed result = new Authed();
149 | initialize(result);
150 | return result;
151 | }
152 |
153 | public class Authed extends HelloworldRequest {
154 |
155 | private static final String REST_PATH = "hellogreeting/authed";
156 |
157 | /**
158 | * Create a request for the method "greetings.authed".
159 | *
160 | * This request holds the parameters needed by the the helloworld server. After setting any
161 | * optional parameters, call the {@link Authed#execute()} method to invoke the remote operation.
162 | *
{@link
163 | * Authed#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)} must
164 | * be called to initialize this instance immediately after invoking the constructor.
165 | *
166 | * @since 1.13
167 | */
168 | protected Authed() {
169 | super(Helloworld.this, "POST", REST_PATH, null, com.appspot.your_app_id.helloworld.model.HelloGreeting.class);
170 | }
171 |
172 | @Override
173 | public Authed setAlt(java.lang.String alt) {
174 | return (Authed) super.setAlt(alt);
175 | }
176 |
177 | @Override
178 | public Authed setFields(java.lang.String fields) {
179 | return (Authed) super.setFields(fields);
180 | }
181 |
182 | @Override
183 | public Authed setKey(java.lang.String key) {
184 | return (Authed) super.setKey(key);
185 | }
186 |
187 | @Override
188 | public Authed setOauthToken(java.lang.String oauthToken) {
189 | return (Authed) super.setOauthToken(oauthToken);
190 | }
191 |
192 | @Override
193 | public Authed setPrettyPrint(java.lang.Boolean prettyPrint) {
194 | return (Authed) super.setPrettyPrint(prettyPrint);
195 | }
196 |
197 | @Override
198 | public Authed setQuotaUser(java.lang.String quotaUser) {
199 | return (Authed) super.setQuotaUser(quotaUser);
200 | }
201 |
202 | @Override
203 | public Authed setUserIp(java.lang.String userIp) {
204 | return (Authed) super.setUserIp(userIp);
205 | }
206 |
207 | @Override
208 | public Authed set(String parameterName, Object value) {
209 | return (Authed) super.set(parameterName, value);
210 | }
211 | }
212 | /**
213 | * Create a request for the method "greetings.getGreeting".
214 | *
215 | * This request holds the parameters needed by the helloworld server. After setting any optional
216 | * parameters, call the {@link GetGreeting#execute()} method to invoke the remote operation.
217 | *
218 | * @param id
219 | * @return the request
220 | */
221 | public GetGreeting getGreeting(java.lang.Integer id) throws java.io.IOException {
222 | GetGreeting result = new GetGreeting(id);
223 | initialize(result);
224 | return result;
225 | }
226 |
227 | public class GetGreeting extends HelloworldRequest {
228 |
229 | private static final String REST_PATH = "hellogreeting/{id}";
230 |
231 | /**
232 | * Create a request for the method "greetings.getGreeting".
233 | *
234 | * This request holds the parameters needed by the the helloworld server. After setting any
235 | * optional parameters, call the {@link GetGreeting#execute()} method to invoke the remote
236 | * operation.
{@link
237 | * GetGreeting#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
238 | * must be called to initialize this instance immediately after invoking the constructor.
239 | *
240 | * @param id
241 | * @since 1.13
242 | */
243 | protected GetGreeting(java.lang.Integer id) {
244 | super(Helloworld.this, "GET", REST_PATH, null, com.appspot.your_app_id.helloworld.model.HelloGreeting.class);
245 | this.id = com.google.api.client.util.Preconditions.checkNotNull(id, "Required parameter id must be specified.");
246 | }
247 |
248 | @Override
249 | public com.google.api.client.http.HttpResponse executeUsingHead() throws java.io.IOException {
250 | return super.executeUsingHead();
251 | }
252 |
253 | @Override
254 | public com.google.api.client.http.HttpRequest buildHttpRequestUsingHead() throws java.io.IOException {
255 | return super.buildHttpRequestUsingHead();
256 | }
257 |
258 | @Override
259 | public GetGreeting setAlt(java.lang.String alt) {
260 | return (GetGreeting) super.setAlt(alt);
261 | }
262 |
263 | @Override
264 | public GetGreeting setFields(java.lang.String fields) {
265 | return (GetGreeting) super.setFields(fields);
266 | }
267 |
268 | @Override
269 | public GetGreeting setKey(java.lang.String key) {
270 | return (GetGreeting) super.setKey(key);
271 | }
272 |
273 | @Override
274 | public GetGreeting setOauthToken(java.lang.String oauthToken) {
275 | return (GetGreeting) super.setOauthToken(oauthToken);
276 | }
277 |
278 | @Override
279 | public GetGreeting setPrettyPrint(java.lang.Boolean prettyPrint) {
280 | return (GetGreeting) super.setPrettyPrint(prettyPrint);
281 | }
282 |
283 | @Override
284 | public GetGreeting setQuotaUser(java.lang.String quotaUser) {
285 | return (GetGreeting) super.setQuotaUser(quotaUser);
286 | }
287 |
288 | @Override
289 | public GetGreeting setUserIp(java.lang.String userIp) {
290 | return (GetGreeting) super.setUserIp(userIp);
291 | }
292 |
293 | @com.google.api.client.util.Key
294 | private java.lang.Integer id;
295 |
296 | /**
297 |
298 | */
299 | public java.lang.Integer getId() {
300 | return id;
301 | }
302 |
303 | public GetGreeting setId(java.lang.Integer id) {
304 | this.id = id;
305 | return this;
306 | }
307 |
308 | @Override
309 | public GetGreeting set(String parameterName, Object value) {
310 | return (GetGreeting) super.set(parameterName, value);
311 | }
312 | }
313 | /**
314 | * Create a request for the method "greetings.listGreeting".
315 | *
316 | * This request holds the parameters needed by the helloworld server. After setting any optional
317 | * parameters, call the {@link ListGreeting#execute()} method to invoke the remote operation.
318 | *
319 | * @return the request
320 | */
321 | public ListGreeting listGreeting() throws java.io.IOException {
322 | ListGreeting result = new ListGreeting();
323 | initialize(result);
324 | return result;
325 | }
326 |
327 | public class ListGreeting extends HelloworldRequest {
328 |
329 | private static final String REST_PATH = "hellogreeting";
330 |
331 | /**
332 | * Create a request for the method "greetings.listGreeting".
333 | *
334 | * This request holds the parameters needed by the the helloworld server. After setting any
335 | * optional parameters, call the {@link ListGreeting#execute()} method to invoke the remote
336 | * operation.
{@link
337 | * ListGreeting#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
338 | * must be called to initialize this instance immediately after invoking the constructor.
339 | *
340 | * @since 1.13
341 | */
342 | protected ListGreeting() {
343 | super(Helloworld.this, "GET", REST_PATH, null, com.appspot.your_app_id.helloworld.model.HelloGreetingCollection.class);
344 | }
345 |
346 | @Override
347 | public com.google.api.client.http.HttpResponse executeUsingHead() throws java.io.IOException {
348 | return super.executeUsingHead();
349 | }
350 |
351 | @Override
352 | public com.google.api.client.http.HttpRequest buildHttpRequestUsingHead() throws java.io.IOException {
353 | return super.buildHttpRequestUsingHead();
354 | }
355 |
356 | @Override
357 | public ListGreeting setAlt(java.lang.String alt) {
358 | return (ListGreeting) super.setAlt(alt);
359 | }
360 |
361 | @Override
362 | public ListGreeting setFields(java.lang.String fields) {
363 | return (ListGreeting) super.setFields(fields);
364 | }
365 |
366 | @Override
367 | public ListGreeting setKey(java.lang.String key) {
368 | return (ListGreeting) super.setKey(key);
369 | }
370 |
371 | @Override
372 | public ListGreeting setOauthToken(java.lang.String oauthToken) {
373 | return (ListGreeting) super.setOauthToken(oauthToken);
374 | }
375 |
376 | @Override
377 | public ListGreeting setPrettyPrint(java.lang.Boolean prettyPrint) {
378 | return (ListGreeting) super.setPrettyPrint(prettyPrint);
379 | }
380 |
381 | @Override
382 | public ListGreeting setQuotaUser(java.lang.String quotaUser) {
383 | return (ListGreeting) super.setQuotaUser(quotaUser);
384 | }
385 |
386 | @Override
387 | public ListGreeting setUserIp(java.lang.String userIp) {
388 | return (ListGreeting) super.setUserIp(userIp);
389 | }
390 |
391 | @Override
392 | public ListGreeting set(String parameterName, Object value) {
393 | return (ListGreeting) super.set(parameterName, value);
394 | }
395 | }
396 | /**
397 | * Create a request for the method "greetings.multiply".
398 | *
399 | * This request holds the parameters needed by the helloworld server. After setting any optional
400 | * parameters, call the {@link Multiply#execute()} method to invoke the remote operation.
401 | *
402 | * @param times
403 | * @param content the {@link com.appspot.your_app_id.helloworld.model.HelloGreeting}
404 | * @return the request
405 | */
406 | public Multiply multiply(java.lang.Integer times, com.appspot.your_app_id.helloworld.model.HelloGreeting content) throws java.io.IOException {
407 | Multiply result = new Multiply(times, content);
408 | initialize(result);
409 | return result;
410 | }
411 |
412 | public class Multiply extends HelloworldRequest {
413 |
414 | private static final String REST_PATH = "hellogreeting/{times}";
415 |
416 | /**
417 | * Create a request for the method "greetings.multiply".
418 | *
419 | * This request holds the parameters needed by the the helloworld server. After setting any
420 | * optional parameters, call the {@link Multiply#execute()} method to invoke the remote operation.
421 | *
{@link
422 | * Multiply#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
423 | * must be called to initialize this instance immediately after invoking the constructor.
Google GSON: {@code com.google.api.client.json.gson.GsonFactory}
519 | *
Android Honeycomb or higher:
520 | * {@code com.google.api.client.extensions.android.json.AndroidJsonFactory}
521 | *
522 | * @param httpRequestInitializer HTTP request initializer or {@code null} for none
523 | * @since 1.7
524 | */
525 | public Builder(com.google.api.client.http.HttpTransport transport, com.google.api.client.json.JsonFactory jsonFactory,
526 | com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
527 | super(
528 | transport,
529 | jsonFactory,
530 | DEFAULT_ROOT_URL,
531 | DEFAULT_SERVICE_PATH,
532 | httpRequestInitializer,
533 | false);
534 | }
535 |
536 | /** Builds a new instance of {@link Helloworld}. */
537 | @Override
538 | public Helloworld build() {
539 | return new Helloworld(this);
540 | }
541 |
542 | @Override
543 | public Builder setRootUrl(String rootUrl) {
544 | return (Builder) super.setRootUrl(rootUrl);
545 | }
546 |
547 | @Override
548 | public Builder setServicePath(String servicePath) {
549 | return (Builder) super.setServicePath(servicePath);
550 | }
551 |
552 | @Override
553 | public Builder setHttpRequestInitializer(com.google.api.client.http.HttpRequestInitializer httpRequestInitializer) {
554 | return (Builder) super.setHttpRequestInitializer(httpRequestInitializer);
555 | }
556 |
557 | @Override
558 | public Builder setApplicationName(String applicationName) {
559 | return (Builder) super.setApplicationName(applicationName);
560 | }
561 |
562 | @Override
563 | public Builder setSuppressPatternChecks(boolean suppressPatternChecks) {
564 | return (Builder) super.setSuppressPatternChecks(suppressPatternChecks);
565 | }
566 |
567 | @Override
568 | public Builder setSuppressRequiredParameterChecks(boolean suppressRequiredParameterChecks) {
569 | return (Builder) super.setSuppressRequiredParameterChecks(suppressRequiredParameterChecks);
570 | }
571 |
572 | @Override
573 | public Builder setSuppressAllChecks(boolean suppressAllChecks) {
574 | return (Builder) super.setSuppressAllChecks(suppressAllChecks);
575 | }
576 |
577 | /**
578 | * Set the {@link HelloworldRequestInitializer}.
579 | *
580 | * @since 1.12
581 | */
582 | public Builder setHelloworldRequestInitializer(
583 | HelloworldRequestInitializer helloworldRequestInitializer) {
584 | return (Builder) super.setGoogleClientRequestInitializer(helloworldRequestInitializer);
585 | }
586 |
587 | @Override
588 | public Builder setGoogleClientRequestInitializer(
589 | com.google.api.client.googleapis.services.GoogleClientRequestInitializer googleClientRequestInitializer) {
590 | return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
591 | }
592 | }
593 | }
594 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/appspot/your_app_id/helloworld/HelloworldRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
3 | * in compliance with the License. You may obtain a copy of the License at
4 | *
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | *
7 | * Unless required by applicable law or agreed to in writing, software distributed under the License
8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 | * or implied. See the License for the specific language governing permissions and limitations under
10 | * the License.
11 | */
12 | /*
13 | * This code was generated by https://code.google.com/p/google-apis-client-generator/
14 | * (build: 2013-09-16 16:01:30 UTC)
15 | * on 2013-09-30 at 22:19:22 UTC
16 | * Modify at your own risk.
17 | */
18 |
19 | package com.appspot.your_app_id.helloworld;
20 |
21 | /**
22 | * Helloworld request.
23 | *
24 | * @since 1.3
25 | */
26 | @SuppressWarnings("javadoc")
27 | public abstract class HelloworldRequest extends com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest {
28 |
29 | /**
30 | * @param client Google client
31 | * @param method HTTP Method
32 | * @param uriTemplate URI template for the path relative to the base URL. If it starts with a "/"
33 | * the base path from the base URL will be stripped out. The URI template can also be a
34 | * full URL. URI template expansion is done using
35 | * {@link com.google.api.client.http.UriTemplate#expand(String, String, Object, boolean)}
36 | * @param content A POJO that can be serialized into JSON or {@code null} for none
37 | * @param responseClass response class to parse into
38 | */
39 | public HelloworldRequest(
40 | Helloworld client, String method, String uriTemplate, Object content, Class responseClass) {
41 | super(
42 | client,
43 | method,
44 | uriTemplate,
45 | content,
46 | responseClass);
47 | }
48 |
49 | /** Data format for the response. */
50 | @com.google.api.client.util.Key
51 | private java.lang.String alt;
52 |
53 | /**
54 | * Data format for the response. [default: json]
55 | */
56 | public java.lang.String getAlt() {
57 | return alt;
58 | }
59 |
60 | /** Data format for the response. */
61 | public HelloworldRequest setAlt(java.lang.String alt) {
62 | this.alt = alt;
63 | return this;
64 | }
65 |
66 | /** Selector specifying which fields to include in a partial response. */
67 | @com.google.api.client.util.Key
68 | private java.lang.String fields;
69 |
70 | /**
71 | * Selector specifying which fields to include in a partial response.
72 | */
73 | public java.lang.String getFields() {
74 | return fields;
75 | }
76 |
77 | /** Selector specifying which fields to include in a partial response. */
78 | public HelloworldRequest setFields(java.lang.String fields) {
79 | this.fields = fields;
80 | return this;
81 | }
82 |
83 | /**
84 | * API key. Your API key identifies your project and provides you with API access, quota, and
85 | * reports. Required unless you provide an OAuth 2.0 token.
86 | */
87 | @com.google.api.client.util.Key
88 | private java.lang.String key;
89 |
90 | /**
91 | * API key. Your API key identifies your project and provides you with API access, quota, and
92 | * reports. Required unless you provide an OAuth 2.0 token.
93 | */
94 | public java.lang.String getKey() {
95 | return key;
96 | }
97 |
98 | /**
99 | * API key. Your API key identifies your project and provides you with API access, quota, and
100 | * reports. Required unless you provide an OAuth 2.0 token.
101 | */
102 | public HelloworldRequest setKey(java.lang.String key) {
103 | this.key = key;
104 | return this;
105 | }
106 |
107 | /** OAuth 2.0 token for the current user. */
108 | @com.google.api.client.util.Key("oauth_token")
109 | private java.lang.String oauthToken;
110 |
111 | /**
112 | * OAuth 2.0 token for the current user.
113 | */
114 | public java.lang.String getOauthToken() {
115 | return oauthToken;
116 | }
117 |
118 | /** OAuth 2.0 token for the current user. */
119 | public HelloworldRequest setOauthToken(java.lang.String oauthToken) {
120 | this.oauthToken = oauthToken;
121 | return this;
122 | }
123 |
124 | /** Returns response with indentations and line breaks. */
125 | @com.google.api.client.util.Key
126 | private java.lang.Boolean prettyPrint;
127 |
128 | /**
129 | * Returns response with indentations and line breaks. [default: true]
130 | */
131 | public java.lang.Boolean getPrettyPrint() {
132 | return prettyPrint;
133 | }
134 |
135 | /** Returns response with indentations and line breaks. */
136 | public HelloworldRequest setPrettyPrint(java.lang.Boolean prettyPrint) {
137 | this.prettyPrint = prettyPrint;
138 | return this;
139 | }
140 |
141 | /**
142 | * Available to use for quota purposes for server-side applications. Can be any arbitrary string
143 | * assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
144 | */
145 | @com.google.api.client.util.Key
146 | private java.lang.String quotaUser;
147 |
148 | /**
149 | * Available to use for quota purposes for server-side applications. Can be any arbitrary string
150 | * assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
151 | */
152 | public java.lang.String getQuotaUser() {
153 | return quotaUser;
154 | }
155 |
156 | /**
157 | * Available to use for quota purposes for server-side applications. Can be any arbitrary string
158 | * assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
159 | */
160 | public HelloworldRequest setQuotaUser(java.lang.String quotaUser) {
161 | this.quotaUser = quotaUser;
162 | return this;
163 | }
164 |
165 | /**
166 | * IP address of the site where the request originates. Use this if you want to enforce per-user
167 | * limits.
168 | */
169 | @com.google.api.client.util.Key
170 | private java.lang.String userIp;
171 |
172 | /**
173 | * IP address of the site where the request originates. Use this if you want to enforce per-user
174 | * limits.
175 | */
176 | public java.lang.String getUserIp() {
177 | return userIp;
178 | }
179 |
180 | /**
181 | * IP address of the site where the request originates. Use this if you want to enforce per-user
182 | * limits.
183 | */
184 | public HelloworldRequest setUserIp(java.lang.String userIp) {
185 | this.userIp = userIp;
186 | return this;
187 | }
188 |
189 | @Override
190 | public final Helloworld getAbstractGoogleClient() {
191 | return (Helloworld) super.getAbstractGoogleClient();
192 | }
193 |
194 | @Override
195 | public HelloworldRequest setDisableGZipContent(boolean disableGZipContent) {
196 | return (HelloworldRequest) super.setDisableGZipContent(disableGZipContent);
197 | }
198 |
199 | @Override
200 | public HelloworldRequest setRequestHeaders(com.google.api.client.http.HttpHeaders headers) {
201 | return (HelloworldRequest) super.setRequestHeaders(headers);
202 | }
203 |
204 | @Override
205 | public HelloworldRequest set(String parameterName, Object value) {
206 | return (HelloworldRequest) super.set(parameterName, value);
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/appspot/your_app_id/helloworld/HelloworldRequestInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
3 | * in compliance with the License. You may obtain a copy of the License at
4 | *
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | *
7 | * Unless required by applicable law or agreed to in writing, software distributed under the License
8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 | * or implied. See the License for the specific language governing permissions and limitations under
10 | * the License.
11 | */
12 | /*
13 | * This code was generated by https://code.google.com/p/google-apis-client-generator/
14 | * (build: 2013-09-16 16:01:30 UTC)
15 | * on 2013-09-30 at 22:19:22 UTC
16 | * Modify at your own risk.
17 | */
18 |
19 | package com.appspot.your_app_id.helloworld;
20 |
21 | /**
22 | * Helloworld request initializer for setting properties like key and userIp.
23 | *
24 | *
25 | * The simplest usage is to use it to set the key parameter:
26 | *
27 | *
28 | *
29 | public static final GoogleClientRequestInitializer KEY_INITIALIZER =
30 | new HelloworldRequestInitializer(KEY);
31 | *
32 | *
33 | *
34 | * There is also a constructor to set both the key and userIp parameters:
35 | *
36 | *
37 | *
38 | public static final GoogleClientRequestInitializer INITIALIZER =
39 | new HelloworldRequestInitializer(KEY, USER_IP);
40 | *
41 | *
42 | *
43 | * If you want to implement custom logic, extend it like this:
44 | *
79 | *
80 | * @since 1.12
81 | */
82 | public class HelloworldRequestInitializer extends com.google.api.client.googleapis.services.json.CommonGoogleJsonClientRequestInitializer {
83 |
84 | public HelloworldRequestInitializer() {
85 | super();
86 | }
87 |
88 | /**
89 | * @param key API key or {@code null} to leave it unchanged
90 | */
91 | public HelloworldRequestInitializer(String key) {
92 | super(key);
93 | }
94 |
95 | /**
96 | * @param key API key or {@code null} to leave it unchanged
97 | * @param userIp user IP or {@code null} to leave it unchanged
98 | */
99 | public HelloworldRequestInitializer(String key, String userIp) {
100 | super(key, userIp);
101 | }
102 |
103 | @Override
104 | public final void initializeJsonRequest(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest> request) throws java.io.IOException {
105 | super.initializeJsonRequest(request);
106 | initializeHelloworldRequest((HelloworldRequest>) request);
107 | }
108 |
109 | /**
110 | * Initializes Helloworld request.
111 | *
112 | *
113 | * Default implementation does nothing. Called from
114 | * {@link #initializeJsonRequest(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest)}.
115 | *
116 | *
117 | * @throws java.io.IOException I/O exception
118 | */
119 | protected void initializeHelloworldRequest(HelloworldRequest> request) throws java.io.IOException {
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/appspot/your_app_id/helloworld/HelloworldScopes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
3 | * in compliance with the License. You may obtain a copy of the License at
4 | *
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | *
7 | * Unless required by applicable law or agreed to in writing, software distributed under the License
8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 | * or implied. See the License for the specific language governing permissions and limitations under
10 | * the License.
11 | */
12 | /*
13 | * This code was generated by https://code.google.com/p/google-apis-client-generator/
14 | * (build: 2013-09-16 16:01:30 UTC)
15 | * on 2013-09-30 at 22:19:22 UTC
16 | * Modify at your own risk.
17 | */
18 |
19 | package com.appspot.your_app_id.helloworld;
20 |
21 | /**
22 | * Available OAuth 2.0 scopes for use with the helloworld.
23 | *
24 | * @since 1.4
25 | */
26 | public class HelloworldScopes {
27 |
28 | /** View your email address. */
29 | public static final String USERINFO_EMAIL = "https://www.googleapis.com/auth/userinfo.email";
30 |
31 | /**
32 | * Returns an unmodifiable set that contains all scopes declared by this class.
33 | *
34 | * @since 1.16
35 | */
36 | public static java.util.Set all() {
37 | java.util.Set set = new java.util.HashSet();
38 | set.add(USERINFO_EMAIL);
39 | return java.util.Collections.unmodifiableSet(set);
40 | }
41 |
42 | private HelloworldScopes() {
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/appspot/your_app_id/helloworld/model/HelloGreeting.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
3 | * in compliance with the License. You may obtain a copy of the License at
4 | *
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | *
7 | * Unless required by applicable law or agreed to in writing, software distributed under the License
8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 | * or implied. See the License for the specific language governing permissions and limitations under
10 | * the License.
11 | */
12 | /*
13 | * This code was generated by https://code.google.com/p/google-apis-client-generator/
14 | * (build: 2013-09-16 16:01:30 UTC)
15 | * on 2013-09-30 at 22:19:22 UTC
16 | * Modify at your own risk.
17 | */
18 |
19 | package com.appspot.your_app_id.helloworld.model;
20 |
21 | /**
22 | * Model definition for HelloGreeting.
23 | *
24 | *
This is the Java data model class that specifies how to parse/serialize into the JSON that is
25 | * transmitted over HTTP when working with the helloworld. For a detailed explanation see:
26 | * http://code.google.com/p/google-http-java-client/wiki/JSON
27 | *
28 | *
29 | * @author Google, Inc.
30 | */
31 | @SuppressWarnings("javadoc")
32 | public final class HelloGreeting extends com.google.api.client.json.GenericJson {
33 |
34 | /**
35 | * The value may be {@code null}.
36 | */
37 | @com.google.api.client.util.Key
38 | private java.lang.String message;
39 |
40 | /**
41 | * @return value or {@code null} for none
42 | */
43 | public java.lang.String getMessage() {
44 | return message;
45 | }
46 |
47 | /**
48 | * @param message message or {@code null} for none
49 | */
50 | public HelloGreeting setMessage(java.lang.String message) {
51 | this.message = message;
52 | return this;
53 | }
54 |
55 | @Override
56 | public HelloGreeting set(String fieldName, Object value) {
57 | return (HelloGreeting) super.set(fieldName, value);
58 | }
59 |
60 | @Override
61 | public HelloGreeting clone() {
62 | return (HelloGreeting) super.clone();
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/appspot/your_app_id/helloworld/model/HelloGreetingCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
3 | * in compliance with the License. You may obtain a copy of the License at
4 | *
5 | * http://www.apache.org/licenses/LICENSE-2.0
6 | *
7 | * Unless required by applicable law or agreed to in writing, software distributed under the License
8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 | * or implied. See the License for the specific language governing permissions and limitations under
10 | * the License.
11 | */
12 | /*
13 | * This code was generated by https://code.google.com/p/google-apis-client-generator/
14 | * (build: 2013-09-16 16:01:30 UTC)
15 | * on 2013-09-30 at 22:19:22 UTC
16 | * Modify at your own risk.
17 | */
18 |
19 | package com.appspot.your_app_id.helloworld.model;
20 |
21 | /**
22 | * Model definition for HelloGreetingCollection.
23 | *
24 | *
This is the Java data model class that specifies how to parse/serialize into the JSON that is
25 | * transmitted over HTTP when working with the helloworld. For a detailed explanation see:
26 | * http://code.google.com/p/google-http-java-client/wiki/JSON
27 | *
28 | *
29 | * @author Google, Inc.
30 | */
31 | @SuppressWarnings("javadoc")
32 | public final class HelloGreetingCollection extends com.google.api.client.json.GenericJson {
33 |
34 | /**
35 | * The value may be {@code null}.
36 | */
37 | @com.google.api.client.util.Key
38 | private java.util.List items;
39 |
40 | static {
41 | // hack to force ProGuard to consider HelloGreeting used, since otherwise it would be stripped out
42 | // see http://code.google.com/p/google-api-java-client/issues/detail?id=528
43 | com.google.api.client.util.Data.nullOf(HelloGreeting.class);
44 | }
45 |
46 | /**
47 | * @return value or {@code null} for none
48 | */
49 | public java.util.List getItems() {
50 | return items;
51 | }
52 |
53 | /**
54 | * @param items items or {@code null} for none
55 | */
56 | public HelloGreetingCollection setItems(java.util.List items) {
57 | this.items = items;
58 | return this;
59 | }
60 |
61 | @Override
62 | public HelloGreetingCollection set(String fieldName, Object value) {
63 | return (HelloGreetingCollection) super.set(fieldName, value);
64 | }
65 |
66 | @Override
67 | public HelloGreetingCollection clone() {
68 | return (HelloGreetingCollection) super.clone();
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/google/devrel/samples/helloendpoints/AppConstants.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2013 Google Inc. All Rights Reserved.
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | package com.google.devrel.samples.helloendpoints;
17 |
18 | import android.accounts.Account;
19 | import android.accounts.AccountManager;
20 | import android.app.Activity;
21 | import android.app.Dialog;
22 | import android.content.Context;
23 |
24 | import com.google.android.gms.auth.GoogleAuthUtil;
25 | import com.google.android.gms.common.GooglePlayServicesUtil;
26 | import com.google.api.client.extensions.android.http.AndroidHttp;
27 | import com.google.api.client.extensions.android.json.AndroidJsonFactory;
28 | import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
29 | import com.google.api.client.http.HttpTransport;
30 | import com.google.api.client.json.JsonFactory;
31 | import com.appspot.your_app_id.helloworld.Helloworld;
32 |
33 | import javax.annotation.Nullable;
34 |
35 | /**
36 | * Application constants and simple utilities.
37 | */
38 | public class AppConstants {
39 | /**
40 | * Your WEB CLIENT ID from the API Access screen of the Developer Console for your project. This
41 | * is NOT the Android client id from that screen.
42 | *
43 | * @see https://developers.google.com/console
44 | */
45 | public static final String WEB_CLIENT_ID = "your_web_client_id";
46 |
47 | /**
48 | * The audience is defined by the web client id, not the Android client id.
49 | */
50 | public static final String AUDIENCE = "server:client_id:" + WEB_CLIENT_ID;
51 |
52 | /**
53 | * Class instance of the JSON factory.
54 | */
55 | public static final JsonFactory JSON_FACTORY = new AndroidJsonFactory();
56 |
57 | /**
58 | * Class instance of the HTTP transport.
59 | */
60 | public static final HttpTransport HTTP_TRANSPORT = AndroidHttp.newCompatibleTransport();
61 |
62 | /**
63 | * Count Google accounts on the device.
64 | */
65 | public static int countGoogleAccounts(Context context) {
66 | AccountManager am = AccountManager.get(context);
67 | Account[] accounts = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
68 | if (accounts == null || accounts.length < 1) {
69 | return 0;
70 | } else {
71 | return accounts.length;
72 | }
73 | }
74 |
75 | /**
76 | * Retrieve a Helloworld api service handle to access the API.
77 | */
78 | public static Helloworld getApiServiceHandle(@Nullable GoogleAccountCredential credential) {
79 | // Use a builder to help formulate the API request.
80 | Helloworld.Builder helloWorld = new Helloworld.Builder(AppConstants.HTTP_TRANSPORT,
81 | AppConstants.JSON_FACTORY, credential);
82 |
83 | // If running the Cloud Endpoint API locally then point the API stub there by un-commenting the
84 | // next line.
85 | // helloWorld.setRootUrl("http://192.168.1.100:8080/_ah/api/");
86 |
87 | return helloWorld.build();
88 | }
89 |
90 | /**
91 | * Check that Google Play services APK is installed and up to date.
92 | */
93 | public static boolean checkGooglePlayServicesAvailable(Activity activity) {
94 | final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
95 | if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) {
96 | showGooglePlayServicesAvailabilityErrorDialog(activity, connectionStatusCode);
97 | return false;
98 | }
99 | return true;
100 | }
101 |
102 | /**
103 | * Called if the device does not have Google Play Services installed.
104 | */
105 | public static void showGooglePlayServicesAvailabilityErrorDialog(final Activity activity,
106 | final int connectionStatusCode) {
107 | final int REQUEST_GOOGLE_PLAY_SERVICES = 0;
108 | activity.runOnUiThread(new Runnable() {
109 | @Override
110 | public void run() {
111 | Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
112 | connectionStatusCode, activity, REQUEST_GOOGLE_PLAY_SERVICES);
113 | dialog.show();
114 | }
115 | });
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/google/devrel/samples/helloendpoints/Application.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2013 Google Inc. All Rights Reserved.
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | package com.google.devrel.samples.helloendpoints;
17 |
18 | import com.appspot.your_app_id.helloworld.model.HelloGreeting;
19 | import com.google.api.client.util.Lists;
20 |
21 | import java.util.ArrayList;
22 |
23 | /**
24 | * Dummy Application class that can hold static data for use only in sample applications.
25 | *
26 | * TODO(developer): Implement a proper data storage technique for your application.
27 | */
28 | public class Application extends android.app.Application {
29 | ArrayList greetings = Lists.newArrayList();
30 | }
31 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/java/com/google/devrel/samples/helloendpoints/MainActivity.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2013 Google Inc. All Rights Reserved.
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | package com.google.devrel.samples.helloendpoints;
17 |
18 | import android.accounts.Account;
19 | import android.accounts.AccountManager;
20 | import android.content.Intent;
21 | import android.os.AsyncTask;
22 | import android.os.Bundle;
23 | import android.app.Activity;
24 | import android.util.Log;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 | import android.view.WindowManager;
28 | import android.widget.ArrayAdapter;
29 | import android.widget.ListView;
30 | import android.widget.TextView;
31 | import android.widget.Toast;
32 |
33 | import com.google.android.gms.auth.GoogleAuthException;
34 | import com.google.android.gms.auth.GoogleAuthUtil;
35 | import com.google.android.gms.common.AccountPicker;
36 | import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
37 | import com.appspot.your_app_id.helloworld.Helloworld;
38 | import com.appspot.your_app_id.helloworld.Helloworld.Greetings.Authed;
39 | import com.appspot.your_app_id.helloworld.Helloworld.Greetings.GetGreeting;
40 | import com.appspot.your_app_id.helloworld.Helloworld.Greetings.ListGreeting;
41 | import com.appspot.your_app_id.helloworld.Helloworld.Greetings.Multiply;
42 | import com.appspot.your_app_id.helloworld.model.HelloGreeting;
43 | import com.appspot.your_app_id.helloworld.model.HelloGreetingCollection;
44 | import com.google.common.base.Strings;
45 |
46 | import java.io.IOException;
47 | import java.util.Arrays;
48 | import java.util.List;
49 | import java.util.Set;
50 |
51 | import com.google.devrel.samples.helloendpoints.R.id;
52 |
53 | import static com.google.devrel.samples.helloendpoints.BuildConfig.DEBUG;
54 |
55 | /**
56 | * Sample Android application for the Hello World tutorial for Google Cloud Endpoints. The sample
57 | * code shows many of the better practices described in the links below.
58 | *
59 | * @see https://developers.google.com/appengine/docs/java/endpoints
60 | * @see https://developers.google.com/appengine/docs/java/endpoints/consume_android
61 | *
62 | */
63 | public class MainActivity extends Activity {
64 | private static final String LOG_TAG = "MainActivity";
65 |
66 | /**
67 | * Activity result indicating a return from the Google account selection intent.
68 | */
69 | private static final int ACTIVITY_RESULT_FROM_ACCOUNT_SELECTION = 2222;
70 |
71 | private AuthorizationCheckTask mAuthTask;
72 | private String mEmailAccount = "";
73 | private GreetingsDataAdapter listAdapter;
74 |
75 | @Override
76 | protected void onCreate(Bundle savedInstanceState) {
77 | super.onCreate(savedInstanceState);
78 | setContentView(R.layout.activity_main);
79 |
80 | // Prevent the keyboard from being visible upon startup.
81 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
82 |
83 | ListView listView = (ListView)this.findViewById(R.id.greetings_list_view);
84 | listAdapter = new GreetingsDataAdapter((Application)this.getApplication());
85 | listView.setAdapter(listAdapter);
86 | }
87 |
88 | @Override
89 | protected void onDestroy() {
90 | super.onDestroy();
91 | if (mAuthTask!=null) {
92 | mAuthTask.cancel(true);
93 | mAuthTask = null;
94 | }
95 | }
96 |
97 | @Override
98 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
99 | super.onActivityResult(requestCode, resultCode, data);
100 |
101 | if (requestCode == ACTIVITY_RESULT_FROM_ACCOUNT_SELECTION && resultCode == RESULT_OK) {
102 | // This path indicates the account selection activity resulted in the user selecting a
103 | // Google account and clicking OK.
104 |
105 | // Set the selected account.
106 | String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
107 | TextView emailAccountTextView = (TextView)this.findViewById(id.email_address_tv);
108 | emailAccountTextView.setText(accountName);
109 |
110 | // Fire off the authorization check for this account and OAuth2 scopes.
111 | performAuthCheck(accountName);
112 | }
113 | }
114 |
115 | private boolean isSignedIn() {
116 | if (!Strings.isNullOrEmpty(mEmailAccount)) {
117 | return true;
118 | } else {
119 | return false;
120 | }
121 | }
122 |
123 | /**
124 | * This method is invoked when the "Get Greeting" button is clicked. See activity_main.xml for
125 | * the dynamic reference to this method.
126 | */
127 | public void onClickGetGreeting(View view) {
128 | View rootView = view.getRootView();
129 | TextView greetingIdInputTV = (TextView)rootView.findViewById(R.id.greeting_id_edit_text);
130 | if (greetingIdInputTV.getText()==null ||
131 | Strings.isNullOrEmpty(greetingIdInputTV.getText().toString())) {
132 | Toast.makeText(this, "Input a Greeting ID", Toast.LENGTH_SHORT).show();
133 | return;
134 | };
135 |
136 | String greetingIdString = greetingIdInputTV.getText().toString();
137 | int greetingId = Integer.parseInt(greetingIdString);
138 |
139 | // Use of an anonymous class is done for sample code simplicity. {@code AsyncTasks} should be
140 | // static-inner or top-level classes to prevent memory leak issues.
141 | // @see http://goo.gl/fN1fuE @26:00 for an great explanation.
142 | AsyncTask getAndDisplayGreeting =
143 | new AsyncTask () {
144 | @Override
145 | protected HelloGreeting doInBackground(Integer... integers) {
146 | // Retrieve service handle using null credential since this is an unauthenticated call.
147 | Helloworld apiServiceHandle = AppConstants.getApiServiceHandle(null);
148 |
149 | try {
150 | GetGreeting getGreetingCommand = apiServiceHandle.greetings().getGreeting(integers[0]);
151 | HelloGreeting greeting = getGreetingCommand.execute();
152 | return greeting;
153 | } catch (IOException e) {
154 | Log.e(LOG_TAG, "Exception during API call", e);
155 | }
156 | return null;
157 | }
158 |
159 | @Override
160 | protected void onPostExecute(HelloGreeting greeting) {
161 | if (greeting!=null) {
162 | displayGreetings(greeting);
163 | } else {
164 | Log.e(LOG_TAG, "No greetings were returned by the API.");
165 | }
166 | }
167 | };
168 |
169 | getAndDisplayGreeting.execute(greetingId);
170 | }
171 |
172 | /**
173 | * This method is invoked when the "List Greetings" button is clicked. See activity_main.xml for
174 | * the dynamic reference to this method.
175 | */
176 | public void onClickListGreetings(View unused) {
177 |
178 | // Use of an anonymous class is done for sample code simplicity. {@code AsyncTasks} should be
179 | // static-inner or top-level classes to prevent memory leak issues.
180 | // @see http://goo.gl/fN1fuE @26:00 for an great explanation.
181 | AsyncTask getAndDisplayGreeting =
182 | new AsyncTask () {
183 | @Override
184 | protected HelloGreetingCollection doInBackground(Void... unused) {
185 | // Retrieve service handle using null credential since this is an unauthenticated call.
186 | Helloworld apiServiceHandle = AppConstants.getApiServiceHandle(null);
187 |
188 | try {
189 | ListGreeting getGreetingCommand = apiServiceHandle.greetings().listGreeting();
190 | HelloGreetingCollection greeting = getGreetingCommand.execute();
191 | return greeting;
192 | } catch (IOException e) {
193 | Log.e(LOG_TAG, "Exception during API call", e);
194 | }
195 | return null;
196 | }
197 |
198 | @Override
199 | protected void onPostExecute(HelloGreetingCollection greeting) {
200 | if (greeting!=null && greeting.getItems()!=null) {
201 | displayGreetings(greeting.getItems().toArray(new HelloGreeting[] {}));
202 | } else {
203 | Log.e(LOG_TAG, "No greetings were returned by the API.");
204 | }
205 | }
206 | };
207 |
208 | getAndDisplayGreeting.execute((Void)null);
209 | }
210 |
211 | /**
212 | * This method is invoked when the "Multiply Greeting" button is clicked. See activity_main.xml
213 | * for the dynamic reference to this method.
214 | */
215 | public void onClickSendGreetings(View view) {
216 | View rootView = view.getRootView();
217 |
218 | TextView greetingCountInputTV = (TextView)rootView.findViewById(id.greeting_count_edit_text);
219 | if (greetingCountInputTV.getText()==null ||
220 | Strings.isNullOrEmpty(greetingCountInputTV.getText().toString())) {
221 | Toast.makeText(this, "Input a Greeting Count", Toast.LENGTH_SHORT).show();
222 | return;
223 | };
224 |
225 | String greetingCountString = greetingCountInputTV.getText().toString();
226 | final int greetingCount = Integer.parseInt(greetingCountString);
227 |
228 | TextView greetingTextInputTV = (TextView)rootView.findViewById(id.greeting_text_edit_text);
229 | if (greetingTextInputTV.getText()==null ||
230 | Strings.isNullOrEmpty(greetingTextInputTV.getText().toString())) {
231 | Toast.makeText(this, "Input a Greeting Message", Toast.LENGTH_SHORT).show();
232 | return;
233 | };
234 |
235 | final String greetingMessageString = greetingTextInputTV.getText().toString();
236 |
237 | // Use of an anonymous class is done for sample code simplicity. {@code AsyncTasks} should be
238 | // static-inner or top-level classes to prevent memory leak issues.
239 | // @see http://goo.gl/fN1fuE @26:00 for an great explanation.
240 | AsyncTask sendGreetings = new AsyncTask () {
241 | @Override
242 | protected HelloGreeting doInBackground(Void... unused) {
243 | // Retrieve service handle using null credential since this is an unauthenticated call.
244 | Helloworld apiServiceHandle = AppConstants.getApiServiceHandle(null);
245 |
246 | try {
247 | HelloGreeting greeting = new HelloGreeting();
248 | greeting.setMessage(greetingMessageString);
249 |
250 | Multiply multiplyGreetingCommand = apiServiceHandle.greetings().multiply(greetingCount,
251 | greeting);
252 | greeting = multiplyGreetingCommand.execute();
253 | return greeting;
254 | } catch (IOException e) {
255 | Log.e(LOG_TAG, "Exception during API call", e);
256 | }
257 | return null;
258 | }
259 |
260 | @Override
261 | protected void onPostExecute(HelloGreeting greeting) {
262 | if (greeting!=null) {
263 | displayGreetings(greeting);
264 | } else {
265 | Log.e(LOG_TAG, "No greetings were returned by the API.");
266 | }
267 | }
268 | };
269 |
270 | sendGreetings.execute((Void)null);
271 | }
272 |
273 | /**
274 | * This method is invoked when the "Get Authenticated Greeting" button is clicked. See
275 | * activity_main.xml for the dynamic reference to this method.
276 | */
277 | public void onClickGetAuthenticatedGreeting(View unused) {
278 | if (!isSignedIn()) {
279 | Toast.makeText(this, "You must sign in for this action.", Toast.LENGTH_LONG).show();
280 | return;
281 | }
282 |
283 | // Use of an anonymous class is done for sample code simplicity. {@code AsyncTasks} should be
284 | // static-inner or top-level classes to prevent memory leak issues.
285 | // @see http://goo.gl/fN1fuE @26:00 for an great explanation.
286 | AsyncTask getAuthedGreetingAndDisplay =
287 | new AsyncTask () {
288 | @Override
289 | protected HelloGreeting doInBackground(Void... unused) {
290 | if (!isSignedIn()) {
291 | return null;
292 | };
293 |
294 | if (!AppConstants.checkGooglePlayServicesAvailable(MainActivity.this)) {
295 | return null;
296 | }
297 |
298 | // Create a Google credential since this is an authenticated request to the API.
299 | GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(
300 | MainActivity.this, AppConstants.AUDIENCE);
301 | credential.setSelectedAccountName(mEmailAccount);
302 |
303 | // Retrieve service handle using credential since this is an authenticated call.
304 | Helloworld apiServiceHandle = AppConstants.getApiServiceHandle(credential);
305 |
306 | try {
307 | Authed getAuthedGreetingCommand = apiServiceHandle.greetings().authed();
308 | HelloGreeting greeting = getAuthedGreetingCommand.execute();
309 | return greeting;
310 | } catch (IOException e) {
311 | Log.e(LOG_TAG, "Exception during API call", e);
312 | }
313 | return null;
314 | }
315 |
316 | @Override
317 | protected void onPostExecute(HelloGreeting greeting) {
318 | if (greeting!=null) {
319 | displayGreetings(greeting);
320 | } else {
321 | Log.e(LOG_TAG, "No greetings were returned by the API.");
322 | }
323 | }
324 | };
325 |
326 | getAuthedGreetingAndDisplay.execute((Void)null);
327 | }
328 |
329 | private void displayGreetings(HelloGreeting... greetings) {
330 | String msg;
331 | if (greetings==null || greetings.length < 1) {
332 | msg = "Greeting was not present";
333 | Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
334 | } else {
335 | if (DEBUG) {
336 | Log.d(LOG_TAG, "Displaying " + greetings.length + " greetings.");
337 | }
338 |
339 | List greetingsList = Arrays.asList(greetings);
340 | listAdapter.replaceData(greetings);
341 | }
342 | }
343 |
344 | /**
345 | * This method is invoked when the "Sign In" button is clicked. See activity_main.xml for the
346 | * dynamic reference to this method.
347 | */
348 | public void onClickSignIn(View view) {
349 | TextView emailAddressTV = (TextView) view.getRootView().findViewById(id.email_address_tv);
350 | // Check to see how many Google accounts are registered with the device.
351 | int googleAccounts = AppConstants.countGoogleAccounts(this);
352 | if (googleAccounts == 0) {
353 | // No accounts registered, nothing to do.
354 | Toast.makeText(this, R.string.toast_no_google_accounts_registered,
355 | Toast.LENGTH_LONG).show();
356 | } else if (googleAccounts == 1) {
357 | // If only one account then select it.
358 | Toast.makeText(this, R.string.toast_only_one_google_account_registered,
359 | Toast.LENGTH_LONG).show();
360 | AccountManager am = AccountManager.get(this);
361 | Account[] accounts = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
362 | if (accounts != null && accounts.length > 0) {
363 | // Select account and perform authorization check.
364 | emailAddressTV.setText(accounts[0].name);
365 | mEmailAccount = accounts[0].name;
366 | performAuthCheck(accounts[0].name);
367 | }
368 | } else {
369 | // More than one Google Account is present, a chooser is necessary.
370 |
371 | // Reset selected account.
372 | emailAddressTV.setText("");
373 |
374 | // Invoke an {@code Intent} to allow the user to select a Google account.
375 | Intent accountSelector = AccountPicker.newChooseAccountIntent(null, null,
376 | new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE}, false,
377 | "Select the account to access Google Compute Engine API.", null, null, null);
378 | startActivityForResult(accountSelector,
379 | ACTIVITY_RESULT_FROM_ACCOUNT_SELECTION);
380 | }
381 |
382 | }
383 |
384 | /**
385 | * Schedule the authorization check in an {@code Tasks}.
386 | */
387 | public void performAuthCheck(String emailAccount) {
388 | // Cancel previously running tasks.
389 | if (mAuthTask != null) {
390 | try {
391 | mAuthTask.cancel(true);
392 | } catch (Exception e) {
393 | e.printStackTrace();
394 | }
395 | return;
396 | }
397 |
398 | // Start task to check authorization.
399 | mAuthTask = new AuthorizationCheckTask();
400 | mAuthTask.execute(emailAccount);
401 | }
402 |
403 | /**
404 | * Verifies OAuth2 token access for the application and Google account combination with
405 | * the {@code AccountManager} and the Play Services installed application. If the appropriate
406 | * OAuth2 access hasn't been granted (to this application) then the task may fire an
407 | * {@code Intent} to request that the user approve such access. If the appropriate access does
408 | * exist then the button that will let the user proceed to the next activity is enabled.
409 | */
410 | class AuthorizationCheckTask extends AsyncTask {
411 | @Override
412 | protected Boolean doInBackground(String... emailAccounts) {
413 | Log.i(LOG_TAG, "Background task started.");
414 |
415 | if (!AppConstants.checkGooglePlayServicesAvailable(MainActivity.this)) {
416 | return false;
417 | }
418 |
419 | String emailAccount = emailAccounts[0];
420 | // Ensure only one task is running at a time.
421 | mAuthTask = this;
422 |
423 | // Ensure an email was selected.
424 | if (Strings.isNullOrEmpty(emailAccount)) {
425 | publishProgress(R.string.toast_no_google_account_selected);
426 | // Failure.
427 | return false;
428 | }
429 |
430 | if (DEBUG) {
431 | Log.d(LOG_TAG, "Attempting to get AuthToken for account: " + mEmailAccount);
432 | }
433 |
434 | try {
435 | // If the application has the appropriate access then a token will be retrieved, otherwise
436 | // an error will be thrown.
437 | GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(
438 | MainActivity.this, AppConstants.AUDIENCE);
439 | credential.setSelectedAccountName(emailAccount);
440 |
441 | String accessToken = credential.getToken();
442 |
443 | if (DEBUG) {
444 | Log.d(LOG_TAG, "AccessToken retrieved");
445 | }
446 |
447 | // Success.
448 | return true;
449 | } catch (GoogleAuthException unrecoverableException) {
450 | Log.e(LOG_TAG, "Exception checking OAuth2 authentication.", unrecoverableException);
451 | publishProgress(R.string.toast_exception_checking_authorization);
452 | // Failure.
453 | return false;
454 | } catch (IOException ioException) {
455 | Log.e(LOG_TAG, "Exception checking OAuth2 authentication.", ioException);
456 | publishProgress(R.string.toast_exception_checking_authorization);
457 | // Failure or cancel request.
458 | return false;
459 | }
460 | }
461 |
462 | @Override
463 | protected void onProgressUpdate(Integer... stringIds) {
464 | // Toast only the most recent.
465 | Integer stringId = stringIds[0];
466 | Toast.makeText(MainActivity.this, stringId, Toast.LENGTH_SHORT).show();
467 | }
468 |
469 | @Override
470 | protected void onPreExecute() {
471 | mAuthTask = this;
472 | }
473 |
474 | @Override
475 | protected void onPostExecute(Boolean success) {
476 | TextView emailAddressTV = (TextView) MainActivity.this.findViewById(id.email_address_tv);
477 | if (success) {
478 | // Authorization check successful, set internal variable.
479 | mEmailAccount = emailAddressTV.getText().toString();
480 | } else {
481 | // Authorization check unsuccessful, reset TextView to empty.
482 | emailAddressTV.setText("");
483 | }
484 | mAuthTask = null;
485 | }
486 |
487 | @Override
488 | protected void onCancelled() {
489 | mAuthTask = null;
490 | }
491 | }
492 |
493 | /**
494 | * Simple use of an ArrayAdapter but we're using a static class to ensure no references to the
495 | * Activity exists.
496 | */
497 | static class GreetingsDataAdapter extends ArrayAdapter {
498 | GreetingsDataAdapter(Application application) {
499 | super(application.getApplicationContext(), android.R.layout.simple_list_item_1,
500 | application.greetings);
501 | }
502 |
503 | void replaceData(HelloGreeting[] greetings) {
504 | clear();
505 | for (HelloGreeting greeting : greetings) {
506 | add(greeting);
507 | }
508 | }
509 |
510 | @Override
511 | public View getView(int position, View convertView, ViewGroup parent) {
512 | TextView view = (TextView)super.getView(position, convertView, parent);
513 |
514 | HelloGreeting greeting = (HelloGreeting)this.getItem(position);
515 |
516 | StringBuilder sb = new StringBuilder();
517 |
518 | Set fields = greeting.keySet();
519 | boolean firstLoop = true;
520 | for (String fieldName : fields) {
521 | // Append next line chars to 2.. loop runs.
522 | if (firstLoop) {
523 | firstLoop = false;
524 | } else {
525 | sb.append("\n");
526 | }
527 |
528 | sb.append(fieldName)
529 | .append(": ")
530 | .append(greeting.get(fieldName));
531 | }
532 |
533 | view.setText(sb.toString());
534 | return view;
535 | }
536 | }
537 | }
538 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/appengine-endpoints-helloendpoints-android/e1c51eb7a7403272f3ef24cbfff887729c4edb22/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/appengine-endpoints-helloendpoints-android/e1c51eb7a7403272f3ef24cbfff887729c4edb22/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/appengine-endpoints-helloendpoints-android/e1c51eb7a7403272f3ef24cbfff887729c4edb22/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/appengine-endpoints-helloendpoints-android/e1c51eb7a7403272f3ef24cbfff887729c4edb22/HelloEndpointsProject/HelloEndpoints/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
14 |
15 |
18 |
24 |
25 |
30 |
31 |
32 |
36 |
37 |
41 |
45 |
53 |
59 |
60 |
61 |
65 |
66 |
70 |
71 |
75 |
81 |
82 |
83 |
87 |
88 |
92 |
93 |
97 |
105 |
113 |
119 |
120 |
121 |
125 |
126 |
130 |
131 |
137 |
138 |
141 |
142 |
151 |
152 |
153 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 128dp
5 |
6 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello Endpoints
5 | Settings
6 | Hello world!
7 | No Google Account Selected
8 | Exception checking authorization
9 | No Google Accounts Registered
10 | Your only registered Google account was
11 | selected
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/HelloEndpoints/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/appengine-endpoints-helloendpoints-android/e1c51eb7a7403272f3ef24cbfff887729c4edb22/HelloEndpointsProject/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/HelloEndpointsProject/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Dec 18 15:28:20 PST 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip
7 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/HelloEndpointsProject/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':HelloEndpoints'
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | appengine-endpoints-helloendpoints-android
2 | ==========================================
3 |
4 | 
5 |
6 | This project is no longer actively developed or maintained.
7 |
8 | For new work on this check out [android-docs-samples](https://github.com/GoogleCloudPlatform/android-docs-samples).
9 |
10 | This application is a HelloWorld Android sample application that connects to a
11 | HelloWorld Google Cloud Endpoints backend sample.
12 |
13 | ## Products
14 | - [App Engine][1]
15 |
16 | ## Language
17 | - [Android][2]
18 |
19 | ## APIs
20 | - [Google Cloud Endpoints][3]
21 |
22 | ## Setup Instructions
23 | 1. Deploy a Google Cloud Endpoints [backend sample][9] that this client
24 | app will use as an API server. Proceed with optional authentication steps
25 | during setup.
26 |
27 | 1. Install [Android Studio][7].
28 |
29 | 1. Download code
30 | `git clone https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-android.git`
31 |
32 | 1. Import the project:
33 | 1. Open AndroidStudio and choose "Import Project."
34 | 1. Select the build.gradle file in the HelloEndpointsProject directory and
35 | use default values for the rest of the import screens.
36 | 1. NOTE: If you recieve an import error indicating that "play-services", a
37 | required dependency, could not be found that is OK. It will be resolved by the
38 | following step.
39 |
40 | 1. Check dependencies (even if the project compiles) using the Android SDK
41 | Manager. Ensure the following packages are installed and up-to-date:
42 | 1. Android Support Repository
43 | 1. Android Support Library
44 | 1. Google Play Services
45 | 1. Google Repository
46 |
47 | 1. Close and reopen your project. Clean dependencies using the Build menu
48 | by choosing "Rebuild Project."
49 |
50 | 1. Update the file `HelloEndpointsProject/HelloEndpoints/src/main/java/com/google/api/services/helloworld/Helloworld.java`
51 | with the location of your deployed API. `DEFAULT_ROOT_URL` should include
52 | your App Engine app ID.
53 |
54 | 1. Deploy the Android App
55 | 1. Deploy your app via normal Android deployment procedures.
56 |
57 | ***NOTE: At this point you can deploy the app and all anonymous API calls will work.
58 | The authenticated API call will not work; continue on to configure the Android
59 | application to securely communicate with your backend sample.***
60 |
61 | 1. Register an Android Application to access your Google Cloud Endpoints
62 | backend project.
63 | 1. Navigate to the [Google Cloud Console][8]. Select the Google Cloud
64 | Endpoints Backend project that was deployed as in Step 1.
65 | 1. Navigate to the "APIs & Auth," item of the left menu bar.
66 | 1. Choose the "Credentials" submenu item.
67 | 1. Click "Create new Client ID" and select "Installed Application" and "Android."
68 | 1. Use com.google.devrel.samples.helloendpoints as the package name.
69 | 1. Retrieve your debugging keystore fingerprint from ADB. On a Mac this
70 | command would typically look like this with an empty password:
71 | `keytool -list -v -keystore ~/.android/debug.keystore`
72 | 1. Click "Create Client ID."
73 |
74 | 1. Associate your Google Cloud Endpoints backend project to the Android
75 | application.
76 | 1. Update the file `HelloEngpoints/src/main/java/com/google/devrel/samples/helloendpoints/AppConstants.java`.
77 | `WEB_CLIENT_ID` field should be updated with the web application client ID
78 | that is defined in the "APIs & Auth" -> "Credentials" screen of your Google Cloud Endpoints
79 | backend project. You will be using the Client ID specified for "Compute Engine and App Engine."
80 | 1. You will similarly need to update your Google Cloud Endpoints backend
81 | sample with the Android application client ID as well. **Do not** forget to
82 | recompile your backend app (such as with `mvn clean install` for the Java one).
83 |
84 | 1. Deploy the Android App
85 | 1. Deploy your app via normal Android deployment procedures.
86 | 1. You will need to use a version 17 or later "Google APIs" enabled AVD
87 | definition if you are using an emulator instead of a physical device. Physical
88 | devices need only Google Play (Services) installed to work.
89 |
90 | 1. A quick note about the Client IDs used above for Authentication.
91 | -Client IDs identify applications (client or backend) to Google.
92 | The authenticated APIs in this sample utilize OAuth2 authentication. OAuth2 tokens
93 | are issued to specific Client IDs and therefore the Client IDs can be used
94 | for restricting access to your APIs.
95 | -When you create a Google Cloud Console Project a default Client ID
96 | is created and named for use by the project. When you upload an App Engine
97 | project it uses that Client ID. This becomes the `WEB_CLIENT_ID` referenced
98 | in the Android/iOS/Backend samples.
99 | -When you register the iOS or Android Applications in the Google
100 | Cloud Console you are creating another Client ID. This Client ID is the
101 | one requesting an OAuth2 token from Google for authentication purposes.
102 | When the API is used in an authenticated manner an OAuth2 access token is
103 | sent and opened by Google Cloud Endpoints. The Client ID is extracted from
104 | the token and compared to the backend's declared acceptable Client ID list.
105 |
106 | [1]: https://developers.google.com/appengine
107 | [2]: http://developer.android.com/reference/packages.html
108 | [3]: https://developers.google.com/appengine/docs/java/endpoints/
109 | [4]: https://code.google.com/apis/console
110 | [5]: https://localhost:8888/
111 | [6]: https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-java/blob/master/war/js/render.js
112 | [7]: http://developer.android.com/sdk/installing/studio.html
113 | [8]: http://cloud.google.com/console
114 | [9]: https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-java-maven
115 |
--------------------------------------------------------------------------------