Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- checkNotNull(SENDER_ID, "SENDER_ID");
- GCMRegistrar.checkDevice(this);
- GCMRegistrar.checkManifest(this);
- TextView mDisplay = (TextView) findViewById(R.id.display);
- String regId = "";
- if (!GCMRegistrar.isRegistered(this))
- {
- mDisplay.setText("registering");
- GCMRegistrar.register(this, SENDER_ID);
- regId = GCMRegistrar.getRegistrationId(this);
- String url = "localhost/Google-Cloud-Messaging-Server-Test/registration.php?regId=" + regId;
- Log.i(TAG, "registration url: " + url);
- HttpRequest httprequest = new HttpRequest(url);
- }
- else
- {
- regId = GCMRegistrar.getRegistrationId(this);
- mDisplay.setText(regId);
- Log.v(TAG, "Already registered");
- GCMRegistrar.unregister(this);
- }
- regId = GCMRegistrar.getRegistrationId(this);
- String url = "localhost/Google-Cloud-Messaging-Server-Test/registration.php?regId=" + regId;
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.codeglue.google.cloud.messaging.test"
- android:versionCode="1"
- android:versionName="1.0" >
- <uses-sdk
- android:minSdkVersion="10"
- android:targetSdkVersion="15" />
- <permission
- android:name="com.codeglue.google.cloud.messaging.test.permission.C2D_MESSAGE"
- android:protectionLevel="signature" />
- <uses-permission android:name="com.codeglue.google.cloud.messaging.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=".MainActivity"
- 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.codeglue.google.cloud.messaging.test" />
- </intent-filter>
- </receiver>
- <service android:name=".GCMIntentService" />
- </application>
- </manifest>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
- <permission
- android:name="you_package_name.permission.C2D_MESSAGE"
- android:protectionLevel="signature" />
- <uses-permission
- android:name="you_package_name.permission.C2D_MESSAGE" />
- <!-- This app has permission to register and receive data message. -->
- <uses-permission
- android:name="com.google.android.c2dm.permission.RECEIVE" />
- <receiver
- android:name="com.google.android.gcm.GCMBroadcastReceiver"
- android:permission="com.google.android.c2dm.permission.SEND" >
- <intent-filter>
- <!-- Receives the actual messages. -->
- <action android:name="com.google.android.c2dm.intent.RECEIVE" />
- <!-- Receives the registration id. -->
- <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
- <category android:name="you_package_name" />
- </intent-filter>
- </receiver>
Add Comment
Please, Sign In to add comment