Not receiving push notification using GCM - android

I am implementing push notification using GCM.I m getting the token and instance id successfully, the server is also returning success on sending the notification but i m unable to reveive notification on my phone. Please help!!!
Below is my code
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.appname"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- [START gcm_permission] -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- [END gcm_permission] -->
<permission android:name="com.example.appname.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.appname.permission.C2D_MESSAGE" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<application
android:allowBackup="true"
android:icon="#drawable/appicon"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.NoActionBar">
<activity
android:name=".Outlet.Activities.SplashActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="gcm_test_app_notification_click_action"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".Outlet.Activities.LoginActivity"
android:screenOrientation="portrait" />
<service
android:name="com.paypal.android.sdk.payments.PayPalService"
android:exported="false" />
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
<activity
android:name="io.card.payment.CardIOActivity"
android:configChanges="keyboardHidden|orientation" />
<activity android:name="io.card.payment.DataEntryActivity" />
<!-- [START gcm_receiver] -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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.example.appname" />
<!--<category android:name="gcm.play.android.samples.com.gcmquickstart" />-->
</intent-filter>
</receiver>
<!-- [END gcm_receiver] -->
<!-- [START gcm_listener] -->
<service
android:name="com.example.appname.CommonFiles.Push.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<!-- [END gcm_listener] -->
<!-- [START instanceId_listener] -->
<service
android:name="com.example.appname.CommonFiles.Push.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<!-- [END instanceId_listener] -->
<service
android:name="com.example.appname.CommonFiles.Push.RegistrationIntentService"
android:exported="false">
</service>
</application>
</manifest>
GCMIntentservice class:-
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
public static final int MESSAGE_NOTIFICATION_ID = 435345;
/**
* Called when message is received.
*
* #param from SenderID of the sender.
* #param data Data bundle containing message data as key/value pairs.
* For Set of keys use data.keySet().
*/
// [START receive_message]
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
if (from.startsWith("/topics/")) {
// message received from some topic.
} else {
// normal downstream message.
}
// [START_EXCLUDE]
/**
* Production applications would usually process the message here.
* Eg: - Syncing with server.
* - Store message in local database.
* - Update UI.
*/
/**
* In some cases it may be useful to show a notification indicating to the user
* that a message was received.
*/
sendNotification(message);
// [END_EXCLUDE]
}
// [END receive_message]
/**
* Create and show a simple notification containing the received GCM message.
*
* #param message GCM message received.
*/
private void sendNotification(String message) {
Intent intent = new Intent(this, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("GCM Message")
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(MESSAGE_NOTIFICATION_ID /* ID of notification */, notificationBuilder.build());
}
}
RegisterIntentService:-
public class RegistrationIntentService extends IntentService {
private static final String TAG = "RegIntentService";
private static final String[] TOPICS = {"global"};
UserSession userSession;
public RegistrationIntentService() {
super(TAG);
}
#Override
protected void onHandleIntent(Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
userSession=new UserSession(this);
try {
// [START register_for_gcm]
// Initially this call goes out to the network to retrieve the token, subsequent calls
// are local.
// [START get_token]
InstanceID instanceID = InstanceID.getInstance(this);
// R.string.gcm_defaultSenderId (the Sender ID) is typically derived from google-services.json.
// See https://developers.google.com/cloud-messaging/android/start for details on this file.
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
userSession.saveGCMToken(token);
// [END get_token]
Log.i(TAG, "GCM Registration Token: " + token);
// TODO: Implement this method to send any registration to your app's servers.
sendRegistrationToServer(token);
// Subscribe to topic channels
subscribeTopics(token);
// You should store a boolean that indicates whether the generated token has been
// sent to your server. If the boolean is false, send the token to your server,
// otherwise your server should have already received the token.
sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply();
// [END register_for_gcm]
} catch (Exception e) {
Log.d(TAG, "Failed to complete token refresh", e);
// If an exception happens while fetching the new token or updating our registration data
// on a third-party server, this ensures that we'll attempt the update at a later time.
sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply();
}
// Notify UI that registration has completed, so the progress indicator can be hidden.
Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
/**
* Persist registration to third-party servers.
*
* Modify this method to associate the user's GCM registration token with any server-side account
* maintained by your application.
*
* #param token The new token.
*/
private void sendRegistrationToServer(String token) {
// Add custom implementation, as needed.
GCMHelper gcmHelper = new GCMHelper(this);
gcmHelper.checkRegisterDevice();
}
/**
* Subscribe to any GCM topics of interest, as defined by the TOPICS constant.
*
* #param token GCM token
* #throws IOException if unable to reach the GCM PubSub service
*/
// [START subscribe_topics]
private void subscribeTopics(String token) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance(this);
for (String topic : TOPICS) {
pubSub.subscribe(token, "/topics/" + topic, null);
}
}
// [END subscribe_topics]
}

Change the permission like below and check
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="YOUR_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" />

I have got the soluion to my problem.
Firstly,Corrected these permissions in my app although these do not create problem with new vesrions
<permission
android:name="com.example.appname.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.appname.permission.C2D_MESSAGE" />
Second,The problem was wifi privacy. When I used my company wifi, I coudn't receive message in mobile, since they were blocked GCM server port .
You can use to following links to implement GCM effectively:
https://developers.google.com/cloud-messaging/
https://github.com/codepath/android_guides/wiki/Google-Cloud-Messaging
Happy Coding :)

You have write in manifest
<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
where com.example is your package name.
But your application package name is com.example.appname
So, you have to write
<permission android:name="com.example.appname.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.appname.permission.C2D_MESSAGE" />

Related

Google Cloud Messaging returns Failure: HTTP Status Code: 401

I am using online tool to send Notification to my Device
http://gcm-alert.appspot.com/
http://techzog.com/development/gcm-notification-test-tool-android/
They both returns,
Failure: HTTP Status Code: 401 -Unauthorized
I have followed following steps to implement Google Clound Messaging API
Create Configuration File added it in my Project->app Folder
Created Async Task In Main Activity and write Following Code.
SharedPreferences getPreference= getSharedPreferences("GCMToken", Context.MODE_PRIVATE);
String tokenID= getPreference.getString("tokenID","");
if(tokenID.isEmpty()) {
InstanceID gcmTokenistanceID = InstanceID.getInstance(getApplicationContext());
token = gcmTokenistanceID.getToken(getString(R.string.project_id),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
GCMServiceURL= "MyWebServerURL.com/="+token;
Log.i("TOKEN From IF Condition", token);
saveTokenID(token);
Then I created NotificationService and extend this class with GcmListenerService
public class GCMNotificationService extends GcmListenerService {
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("Test Message from Server");
NotificationManager notificationManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Title")
.setContentText(message);
notificationManager.notify(1, mBuilder.build());
}
Manifest File
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.app.myapp.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.app.myapp.permission.C2D_MESSAGE" />
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true"
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.app.myapp" />
</intent-filter>
</receiver>
<service
android:name="com.app.myapp.GCMNotificationService" android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
Kindly guide me what i am doing wrong here
Add this permission
<uses-permission android:name="android.permission.INTERNET" />

Reject to launch app (GCM)

I download demo app from github (google clound messaging).
If app running, push-msg delivered. If app closed, in adb logs:
05-18 13:47:11.642 657-677/? W/BroadcastQueue: Reject to launch app gcm.play.android.samples.com.gcmquickstart/10137 for broadcast: App Op 48
05-18 13:47:11.647 24244-24244/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=gcm.play.android.samples.com.gcmquickstart (has extras) }
Sources: https://github.com/googlesamples/google-services.git
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gcm.play.android.samples.com.gcmquickstart" >
<!-- [START gcm_permission] -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- [END gcm_permission] -->
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="gcm.play.android.samples.com.gcmquickstart.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>
<!-- [START gcm_receiver] -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="gcm.play.android.samples.com.gcmquickstart" />
</intent-filter>
</receiver>
<!-- [END gcm_receiver] -->
<!-- [START gcm_listener] -->
<service
android:name="gcm.play.android.samples.com.gcmquickstart.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<!-- [END gcm_listener] -->
<!-- [START instanceId_listener] -->
<service
android:name="gcm.play.android.samples.com.gcmquickstart.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<!-- [END instanceId_listener] -->
<service
android:name="gcm.play.android.samples.com.gcmquickstart.RegistrationIntentService"
android:exported="false">
</service>
</application>
</manifest>
GcmListenerService
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
/**
* Called when message is received.
*
* #param from SenderID of the sender.
* #param data Data bundle containing message data as key/value pairs.
* For Set of keys use data.keySet().
*/
// [START receive_message]
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
if (from.startsWith("/topics/")) {
// message received from some topic.
} else {
// normal downstream message.
}
// [START_EXCLUDE]
/**
* Production applications would usually process the message here.
* Eg: - Syncing with server.
* - Store message in local database.
* - Update UI.
*/
/**
* In some cases it may be useful to show a notification indicating to the user
* that a message was received.
*/
sendNotification(message);
// [END_EXCLUDE]
}
// [END receive_message]
/**
* Create and show a simple notification containing the received GCM message.
*
* #param message GCM message received.
*/
private void sendNotification(String message) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_ic_notification)
.setContentTitle("GCM Message")
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
How fix this problem? Should work when app closed or device locked.
Android Stuido 2.1.1
Android Version 5.0

GCM not recieving notification

I am trying to integrate GCM following steps in the google developers site.
I am getting the token but I am not getting any notification from the server.
I have three services
1.MyGcmListenerService.java
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.android.gms.gcm.GcmListenerService;
public class MyGcmListenerService extends GcmListenerService {
private static final String TAG = "MyGcmListenerService";
/**
* Called when message is received.
*
* #param from SenderID of the sender.
* #param data Data bundle containing message data as key/value pairs.
* For Set of keys use data.keySet().
*/
// [START receive_message]
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
// [START_EXCLUDE]
/**
* Production applications would usually process the message here.
* Eg: - Syncing with server.
* - Store message in local database.
* - Update UI.
*/
/**
* In some cases it may be useful to show a notification indicating to the user
* that a message was received.
*/
sendNotification(message);
// [END_EXCLUDE]
}
// [END receive_message]
/**
* Create and show a simple notification containing the received GCM message.
*
* #param message GCM message received.
*/
private void sendNotification(String message) {
Intent intent = new Intent(this, Home.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.uplogo)
.setContentTitle("GCM Message")
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
RegistrationIntentService.java
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.google.android.gms.gcm.GcmPubSub;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
import java.io.IOException;
public class RegistrationIntentService extends IntentService {
private static final String TAG = "RegIntentService";
private static final String[] TOPICS = {"global"};
public RegistrationIntentService() {
super(TAG);
}
#Override
protected void onHandleIntent(Intent intent) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
try {
// [START register_for_gcm]
// Initially this call goes out to the network to retrieve the token, subsequent calls
// are local.
// [START get_token]
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
// [END get_token]
Log.i(TAG, "GCM Registration Token: " + token);
// TODO: Implement this method to send any registration to your app's servers.
sendRegistrationToServer(token);
// Subscribe to topic channels
subscribeTopics(token);
// You should store a boolean that indicates whether the generated token has been
// sent to your server. If the boolean is false, send the token to your server,
// otherwise your server should have already received the token.
sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply();
// [END register_for_gcm]
} catch (Exception e) {
Log.d(TAG, "Failed to complete token refresh", e);
// If an exception happens while fetching the new token or updating our registration data
// on a third-party server, this ensures that we'll attempt the update at a later time.
sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply();
}
// Notify UI that registration has completed, so the progress indicator can be hidden.
Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
/**
* Persist registration to third-party servers.
*
* Modify this method to associate the user's GCM registration token with any server-side account
* maintained by your application.
*
* #param token The new token.
*/
private void sendRegistrationToServer(String token) {
// Add custom implementation, as needed.
}
/**
* Subscribe to any GCM topics of interest, as defined by the TOPICS constant.
*
* #param token GCM token
* #throws IOException if unable to reach the GCM PubSub service
*/
// [START subscribe_topics]
private void subscribeTopics(String token) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance(this);
for (String topic : TOPICS) {
pubSub.subscribe(token, "/topics/" + topic, null);
}
}
// [END subscribe_topics]
}
MyInstanceIDListenerService
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.google.android.gms.iid.InstanceID;
import com.google.android.gms.iid.InstanceIDListenerService;
public class MyInstanceIDListenerService extends InstanceIDListenerService {
private static final String TAG = "MyInstanceIDLS";
/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. This call is initiated by the
* InstanceID provider.
*/
// [START refresh_token]
#Override
public void onTokenRefresh() {
// Fetch updated Instance ID token and notify our app's server of any changes (if applicable).
Intent intent = new Intent(this, RegistrationIntentService.class);
startService(intent);
}
// [END refresh_token]
}
And I am doint this in my splash Screen
SplashScreen.java
mRegistrationBroadcastReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(context);
boolean sentToken = sharedPreferences
.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false);
if (sentToken) {
Toast.makeText(getApplicationContext(),"token sent",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),"token not sent",Toast.LENGTH_LONG).show();
}
}
};
And I have given all the permissions in the manifest.
My Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="app.aguai.medieazy"
android:versionCode="17"
android:versionName="2.0" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<permission
android:name="app.aguai.medieazy.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="app.aguai.medieazy.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="app.aguai.medieazy.permission.C2D_MESSAGE" />
<uses-permission android:name="app.aguai.medieazy.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="#drawable/uplogo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:replace="android:icon" >
<activity
android:name=".activities.Login"
android:label="#string/title_activity_login" >
</activity>
<activity android:name=".activities.Home" >
</activity>
<activity
android:name=".activities.AddAddress"
android:label="#string/title_activity_add_address"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.UploadPrescription"
android:label="#string/title_activity_upload_prescription"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.OrderMedicines"
android:label="#string/title_activity_order_medicines"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.Pharmacies"
android:label="#string/title_activity_pharmacies" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".activities.PharmacyDetails"
android:label="#string/title_activity_pharmacy_details"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.ReviewOrder"
android:label="#string/title_activity_review_order"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.FetchMyOrders"
android:label="#string/title_activity_fetch_my_orders" >
</activity>
<activity
android:name=".activities.MyOrders"
android:label="#string/title_activity_my_orders" >
</activity>
<activity
android:name=".activities.FetchMyOrderDetails"
android:label="#string/title_activity_fetch_my_order_details" >
</activity>
<activity
android:name=".activities.OrderDetails"
android:label="#string/title_activity_order_details"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.AddMeasurements"
android:label="#string/title_activity_add_measurements"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.ViewMeasurements"
android:label="#string/title_activity_view_measurements"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.EditProfile2"
android:label="#string/title_activity_edit_profile2"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.CircleOfCare"
android:label="#string/title_activity_circle_of_care"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.Adherence"
android:label="#string/title_activity_adherence"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.Test"
android:label="#string/title_activity_test" >
</activity>
<activity
android:name=".activities.MyMedications"
android:label="#string/title_activity_my_medications"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.AddMedicine"
android:label="#string/title_activity_add_medicine"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.ReminderPopUp"
android:label="#string/title_activity_reminder_pop_up"
android:theme="#style/AppTheme2" >
</activity>
<service
android:name=".models.RemindService"
android:enabled="true" >
<intent-filter>
<action android:name="app.aguai.medieazy.models.START_SERVICE" />
</intent-filter>
</service>
<service
android:name=".models.SnoozeService"
android:enabled="true" >
<intent-filter>
<action android:name="app.aguai.medieazy.models.START_SERVICE" />
</intent-filter>
</service>
<activity
android:name=".activities.SnoozePopUp"
android:label="#string/title_activity_snooze_pop_up" >
</activity>
<activity
android:name=".activities.MedicineDetails"
android:label="#string/title_activity_medicine_details"
android:theme="#style/AppTheme2" >
</activity>
<activity
android:name=".activities.Signup"
android:label="#string/title_activity_signup" >
</activity>
<activity
android:name=".activities.ReorderDetails"
android:label="#string/title_activity_reorder_details"
android:theme="#style/AppTheme2">
</activity>
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="app.aguai.medieazy" />
</intent-filter>
</receiver>
<service
android:name="app.aguai.medieazy.GCM.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<!-- [END gcm_listener] -->
<!-- [START instanceId_listener] -->
<service
android:name="app.aguai.medieazy.GCM.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<!-- [END instanceId_listener] -->
<service
android:name="app.aguai.medieazy.GCM.RegistrationIntentService"
android:exported="false">
</service>
</application>
Please help.
I figured it out.
When I tried on other phones, it worked.
Actually, my phone is Jellybean and in pre-kitkat versions, we need to add this line in manifest
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
When I did, it worked.

How to solve "Failed to find provider info for com.my.package.urbanairship.provider"?

I'm trying to enable push notifications in my Android app with Urban Airship and GCM. I create an GCM account using the instructions given here and set a development app on Urban Airship. Then I copied code from the sample app shown here.
Now when I run my app I get
E/ActivityThread﹕ Failed to find provider info for com.my.package.urbanairship.provider
and then
E/ActivityThread﹕ Failed to find provider info for com.my.package.urbanairship.provider
E/XXXX - UALib﹕ Failed to insert in UrbanAirshipProvider.
java.lang.IllegalArgumentException: Unknown URL content://com.my.package.urbanairship.provider/preferences
What am I missing?
app/src/main/assets/airshipconfig.properties
developmentAppKey = <my developmentAppKey>
developmentAppSecret = <my developmentAppSecret>
productionAppKey =
productionAppSecret =
gcmSender = <my gcmSender>
inProduction = false
# LogLevel is "VERBOSE", "DEBUG", "INFO", "WARN", "ERROR" or "ASSERT"
developmentLogLevel = DEBUG
productionLogLevel = ERROR
minSdkVersion = 15
app/src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.package" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" /> <!-- Required for Push -->
<!-- Urban airship -->
<permission android:name="com.my.package.permission.UA_DATA" android:protectionLevel="signature" />
<uses-permission android:name="com.my.package.permission.UA_DATA" />
<!-- The two elements above ensure that only this application has access to the Urban Airship provider -->
<!-- GCM -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- This app has permission to register with GCM and receive message -->
<!-- MODIFICATION REQUIRED - Replace PACKAGE_NAME with your package name -->
<permission android:name="com.my.package.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.my.package.permission.C2D_MESSAGE" />
<!-- The two elements above ensure that only this application can receive the messages and registration result -->
<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Urban Airship and GCM -->
<activity android:name="com.urbanairship.CoreActivity"/>
<!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
<!-- Replace the receiver below with your package and class name -->
<receiver android:name=".GCMIntentReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.urbanairship.push.CHANNEL_UPDATED" />
<action android:name="com.urbanairship.push.OPENED" />
<action android:name="com.urbanairship.push.DISMISSED" />
<action android:name="com.urbanairship.push.RECEIVED" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.my.package" />
</intent-filter>
</receiver>
<!-- REQUIRED for PlayServiceUtils.handleAnyPlayServicesError to handle Google Play services recoverable errors. -->
<activity
android:name="com.urbanairship.google.PlayServicesErrorActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<!-- REQUIRED for Urban Airship Push. The priority is important to be set lower than the
application's push intent receiver in order for the push intent receiver to handle push intents
before the core receiver. This allows the application to launch any activities before Urban
Airship performs any actions or falls back to launching the application launch intent. -->
<receiver android:name="com.urbanairship.CoreReceiver"
android:exported="false">
<intent-filter android:priority="-999">
<action android:name="com.urbanairship.push.OPENED" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.my.package" />
</intent-filter>
</receiver>
<!-- REQUIRED for GCM -->
<receiver
android:name="com.urbanairship.push.GCMPushReceiver"
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" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.my.package" />
</intent-filter>
</receiver>
<service android:name="com.urbanairship.push.PushService" android:label="Push Notification Service" />
<!-- ... -->
</application>
</manifest>
app/src/main/java/com/my/package/MyApp
public class MyApp extends Application {
#Override
public void onCreate() {
super.onCreate();
/* ... */
/* Urban Airship */
UAirship.takeOff(this, new UAirship.OnReadyCallback() {
#Override
public void onAirshipReady(UAirship airship) {
// Perform any airship configurations here
// Create a customized default notification factory
DefaultNotificationFactory defaultNotificationFactory = new DefaultNotificationFactory(getApplicationContext());
defaultNotificationFactory.setSmallIconId(R.drawable.ic_launcher);
defaultNotificationFactory.setColor(NotificationCompat.COLOR_DEFAULT);
// Set it
airship.getPushManager().setNotificationFactory(defaultNotificationFactory);
// Enable Push
airship.getPushManager().setPushEnabled(true);
}
});
}
}
app/src/main/java/com/my/package/GCMIntentService
package com.my.package;
import android.content.Context;
import android.util.Log;
import com.urbanairship.push.BaseIntentReceiver;
import com.urbanairship.push.PushMessage;
public class GCMIntentReceiver extends BaseIntentReceiver {
private static final String TAG = "GCMIntentReceiver";
#Override
protected void onChannelRegistrationSucceeded(Context context, String channelId) {
Log.i(TAG, "Channel registration updated. Channel Id:" + channelId + ".");
// Broadcast that the channel updated. Used to refresh the channel ID on the main activity.
//LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(MainActivity.ACTION_UPDATE_CHANNEL));
}
#Override
protected void onChannelRegistrationFailed(Context context) {
Log.i(TAG, "Channel registration failed.");
}
#Override
protected void onPushReceived(Context context, PushMessage message, int notificationId) {
Log.i(TAG, "Received push notification. Alert: " + message.getAlert() + ". Notification ID: " + notificationId);
}
#Override
protected void onBackgroundPushReceived(Context context, PushMessage message) {
Log.i(TAG, "Received background push message: " + message);
}
#Override
protected boolean onNotificationOpened(Context context, PushMessage message, int notificationId) {
Log.i(TAG, "User clicked notification. Alert: " + message.getAlert());
return false;
}
#Override
protected boolean onNotificationActionOpened(Context context, PushMessage message, int notificationId, String buttonId, boolean isForeground) {
Log.i(TAG, "User clicked notification button. Button ID: " + buttonId + " Alert: " + message.getAlert());
return false;
}
#Override
protected void onNotificationDismissed(Context context, PushMessage message, int notificationId) {
Log.i(TAG, "Notification dismissed. Alert: " + message.getAlert() + ". Notification ID: " + notificationId);
}
}
I don't see a provider defined in your manifest. You should have something like this:
<provider
android:name="provider"
android:authorities="com.my.package.urbanairship.provider"
android:exported="false"/>

trying to add push notification to my app

i am trying to add push notification to my app.. i have been following Ravi Tamada's blog for this http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Incidentally i was able to get the individual project running with my sender id and registration id, all push notification worked perfectly.. the problem occurs when i try to implement this in my app.. when the project is being run, the app stops after CHECKING REGID = NULL
the app dose not crash.. it simply stops as intent does not occurs as the server dosn't respond
my bad.. i have multiple packages.. the services have the correct package name.. so does the category
so what s wrong with the app?? why is it not working?
this is my log cat for the app including pushnotifications
onReceive: com.google.android.c2dm.intent.REGISTRATION
GCM IntentService class: com.example.smss.GCMIntentService
V/GCMBaseIntentService(2959): Acquiring wakelock
This is my manifest. .
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smss"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<!-- GCM connects to Internet Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="com.example.smss.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.smss.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.smss.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>
<!-- Register Activity -->
<activity
android:name="com.quinoid.sms.pushnotifications.RegisterActivity"
android:label="#string/app_name" >
</activity>
<!-- Main Activity -->
<activity
android:name="com.quinoid.sms.pushnotifications.InitialActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name" >
</activity>
<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="com.example.smss" />
</intent-filter>
</receiver>
<service android:name="com.quinoid.sms.pushnotifications.GCMIntentService" />
</application>
This is my main class InitialActivity.class
public class InitialActivity extends Activity {
// label to display gcm messages
TextView lblMessage;
// Asyntask
AsyncTask<Void, Void, Void> mRegisterTask;
// Alert dialog manager
AlertDialogManager alert = new AlertDialogManager();
// Connection detector
ConnectionDetector cd;
public static String username;
public static String password;
public static String userid;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main1);
cd = new ConnectionDetector(getApplicationContext());
// Check if Internet present
if (!cd.isConnectingToInternet()) {
// Internet Connection is not present
alert.showAlertDialog(InitialActivity.this,
"Internet Connection Error",
"Please connect to working Internet connection", false);
// stop executing code by return
return;
}
// Getting name, email from intent
Intent i = getIntent();
username = i.getStringExtra("username");
password = i.getStringExtra("password");
userid = i.getStringExtra("userid");
// Make sure the device has the proper dependencies.
GCMRegistrar.checkDevice(this);
// Make sure the manifest was properly set - comment out this line
// while developing the app, then uncomment it when it's ready.
GCMRegistrar.checkManifest(this);
lblMessage = (TextView) findViewById(R.id.lblMessage);
registerReceiver(mHandleMessageReceiver, new IntentFilter(
DISPLAY_MESSAGE_ACTION));
// Get GCM registration id
final String regId = GCMRegistrar.getRegistrationId(this);
// Check if regid already presents
if (regId.equals("")) {
// Registration is not present, register now with GCM
GCMRegistrar.register(this, SENDER_ID);
lblMessage.append("inside first if condition where regid = null" + "\n\n");
} else {
// Device is already registered on GCM
if (GCMRegistrar.isRegisteredOnServer(this)) {
// Skips registration.
Toast.makeText(getApplicationContext(), "Already registered with GCM", Toast.LENGTH_LONG).show();
} else {
// Try to register again, but not in the UI thread.
// It's also necessary to cancel the thread onDestroy(),
// hence the use of AsyncTask instead of a raw thread.
lblMessage.append("inside 2nd if condition where regid != null and GCMRegistrar.isRegisteredOnServer(this) = false " + "\n");
final Context context = this;
mRegisterTask = new AsyncTask<Void, Void, Void>() {
#Override
protected Void doInBackground(Void... params) {
// Register on our server
// On server creates a new user
lblMessage.append("inside doinbackground" + "\n\n");
ServerUtilities.register(context, username, password, regId);
return null;
}
#Override
protected void onPostExecute(Void result) {
mRegisterTask = null;
}
};
mRegisterTask.execute(null, null, null);
}
}
}
/**
* Receiving push messages
* */
private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
lblMessage.append("inside BroadcastReceiver mHandleMessageReceiver " + "\n\n");
String newMessage = intent.getExtras().getString(EXTRA_MESSAGE);
// Waking up mobile if it is sleeping
WakeLocker.acquire(getApplicationContext());
/**
* Take appropriate action on this message
* depending upon your app requirement
* For now i am just displaying it on the screen
* */
// Showing received message
lblMessage.append(newMessage + "\n");
Toast.makeText(getApplicationContext(), "New Message: " + newMessage, Toast.LENGTH_LONG).show();
// Releasing wake lock
WakeLocker.release();
if(newMessage.equals("From Demo Server: successfully added device!"))
{
Intent myIntent = new Intent(InitialActivity.this,homepage.class);
myIntent.putExtra("userid", userid);
startActivity(myIntent);
}
}
};
#Override
protected void onDestroy() {
if (mRegisterTask != null) {
mRegisterTask.cancel(true);
}
try {
unregisterReceiver(mHandleMessageReceiver);
GCMRegistrar.onDestroy(this);
} catch (Exception e) {
Log.e("UnRegister Receiver Error", "> " + e.getMessage());
}
super.onDestroy();
}
}
my log cat!!!!
D/dalvikvm(2959): GC_FOR_ALLOC freed 62K, 18% free 8937K/10848K, paused 35ms, total 41ms
I/System.out(2959): the readerjava.io.BufferedReader#b24bf900
I/System.out(2959): value of login = {"Login":"Success","UserId":"3"}
I/ActivityManager(395): START u0 {cmp=com.example.smss/com.quinoid.sms.pushnotifications.InitialActivity (has extras)} from pid 2959
W/InputMethodManagerService(395): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#b275fd28 attribute=null, token = android.os.BinderProxy#b22865e8
D/GCMRegistrar(2959): resetting backoff for com.example.smss
V/GCMRegistrar(2959): Registering app com.example.smss of senders 170214588075
I/Choreographer(2959): Skipped 115 frames! The application may be doing too much work on its main thread.
V/GCMBroadcastReceiver(2959): onReceive: com.google.android.c2dm.intent.REGISTRATION
V/GCMBroadcastReceiver(2959): GCM IntentService class: com.example.smss.GCMIntentService
V/GCMBaseIntentService(2959): Acquiring wakelock
W/ActivityManager(395): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.example.smss cmp=com.example.smss/.GCMIntentService (has extras) } U=0: not found
I/ActivityManager(395): Displayed com.example.smss/com.quinoid.sms.pushnotifications.InitialActivity: +3s309ms
seems that you have not implemented the GCMIntentService class correctly. do this in your AndroidManifest.xml:
<service android:name="com.example.smss.GCMIntentService" />
and also create the corresponding class in the correct package name. For the rest you can follow the tutorial..
hello there are so many code missing in Android menifest file see my below code and check your google-play service lib and metadata for that...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ex_gcmdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<permission android:name="com.example.ex_gcmdemo.permission.C2D_MESSAGE" android:protectionLevel="signature"></permission>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.example.ex_gcmdemo.permission.C2D_MESSAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.ex_gcmdemo.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="GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter >
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.example.ex_gcmdemo"/>
</intent-filter>
</receiver>
<service android:name="GcmIntentService"></service>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity android:name="HomePage"></activity>
</application>
</manifest>

Categories

Resources