Permalink
Browse files

Add Android app for testing GCM.

  • Loading branch information...
1 parent 76078cf commit e6c1dac48139f66193e36e8c0fc125a15383b42c @ileitch committed Sep 2, 2012
View
@@ -6,3 +6,4 @@ coverage/
.rbx/
spec/acceptance/fixtures
.rbenv-version
+gcm_test/bin
View
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="lib" path="libs/gcm.jar"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
View
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>gcm_test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,5 @@
+#Sat Sep 01 12:14:00 PDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.github.ileitch.rapns.gcm_test"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="15"
+ android:targetSdkVersion="15" />
+
+ <permission
+ android:name="com.github.ileitch.rapns.gcm_test.permission.C2D_MESSAGE"
+ android:protectionLevel="signature" />
+
+ <uses-permission android:name="com.github.ileitch.rapns.gcm_test.permission.C2D_MESSAGE" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".GcmTestActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <receiver
+ android:name="com.google.android.gcm.GCMBroadcastReceiver"
+ android:permission="com.google.android.c2dm.permission.SEND" >
+ <intent-filter>
+ <action android:name="com.google.android.c2dm.intent.RECEIVE" />
+ <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
+
+ <category android:name="com.github.ileitch.rapns.gcm_test" />
+ </intent-filter>
+ </receiver>
+
+ <service android:name=".GCMIntentService" />
+ </application>
+
+</manifest>
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.github.ileitch.rapns.gcm_test;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
@@ -0,0 +1,14 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.github.ileitch.rapns.gcm_test;
+
+public final class Manifest {
+ public static final class permission {
+ public static final String C2D_MESSAGE="com.github.ileitch.rapns.gcm_test.permission.C2D_MESSAGE";
+ }
+}
@@ -0,0 +1,26 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.github.ileitch.rapns.gcm_test;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ }
+ public static final class id {
+ public static final int display=0x7f050000;
+ }
+ public static final class layout {
+ public static final int main=0x7f030000;
+ }
+ public static final class string {
+ public static final int app_name=0x7f040001;
+ public static final int hello=0x7f040000;
+ }
+}
View
Binary file not shown.
View
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-15
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <TextView
+ android:id="@+id/display"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textColor="#ffffff" />
+
+</ScrollView>
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="hello">Hello World, GcmTestActivity!</string>
+ <string name="app_name">GcmTest</string>
+
+</resources>
@@ -0,0 +1,5 @@
+package com.github.ileitch.rapns.gcm_test;
+
+public class CommonUtilities {
+ static final String SENDER_ID = "312204035594";
+}
@@ -0,0 +1,42 @@
+package com.github.ileitch.rapns.gcm_test;
+
+import static com.github.ileitch.rapns.gcm_test.CommonUtilities.SENDER_ID;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import com.google.android.gcm.GCMBaseIntentService;
+
+public class GCMIntentService extends GCMBaseIntentService {
+
+ public GCMIntentService() {
+ super(SENDER_ID);
+ }
+
+ private static final String TAG = "===GCMIntentService===";
+
+ @Override
+ protected void onRegistered(Context arg0, String registrationId) {
+ Log.i(TAG, "Device registered: regId = " + registrationId);
+ }
+
+ @Override
+ protected void onUnregistered(Context arg0, String arg1) {
+ Log.i(TAG, "unregistered = " + arg1);
+ }
+
+ @Override
+ protected void onMessage(Context arg0, Intent arg1) {
+ Log.i(TAG, "new message= "+ arg1.getStringExtra("message"));
+ }
+
+ @Override
+ protected void onError(Context arg0, String errorId) {
+ Log.i(TAG, "Received error: " + errorId);
+ }
+
+ @Override
+ protected boolean onRecoverableError(Context context, String errorId) {
+ return super.onRecoverableError(context, errorId);
+ }
+}
@@ -0,0 +1,51 @@
+package com.github.ileitch.rapns.gcm_test;
+
+import static com.github.ileitch.rapns.gcm_test.CommonUtilities.SENDER_ID;
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.TextView;
+
+import com.google.android.gcm.GCMRegistrar;
+
+public class GcmTestActivity extends Activity {
+
+ private String TAG = "** pushAndroidActivity **";
+ private TextView mDisplay;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ checkNotNull(SENDER_ID, "SENDER_ID");
+
+ GCMRegistrar.checkDevice(this);
+ GCMRegistrar.checkManifest(this);
+
+ setContentView(R.layout.main);
+ mDisplay = (TextView) findViewById(R.id.display);
+
+ final String regId = GCMRegistrar.getRegistrationId(this);
+ Log.i(TAG, "registration id =====&nbsp; " + regId);
+
+ if (regId.equals("")) {
+ GCMRegistrar.register(this, SENDER_ID);
+ } else {
+ Log.v(TAG, "Already registered");
+ }
+
+ mDisplay.setText(regId);
+ }
+
+ private void checkNotNull(Object reference, String name) {
+ if (reference == null) {
+ throw new NullPointerException(name);
+ }
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ GCMRegistrar.unregister(this);
+ }
+}

0 comments on commit e6c1dac

Please sign in to comment.