Not receiving notification when the app is running in background,

Hello, i’m posting full code which i have written, i’m getting notification inside the handleResponse method when the app is running. But if i quit the app, i wont get any notification in the background.
Here is the full code, correct me where is the mistake. Please

public class MainActivity extends AppCompatActivity {
private static final String YOUR_APP_ID = “2C25D658-240D-4350-FF8A-6CF4DBD88F00”;
private static final String YOUR_SECRET_KEY = “24DB6F44-8C97-1DCF-FF22-060777780600”;
String appVersion = “v1”;
Subscription subscription;
protected void onCreate(Bundle savedInstanceState) {
Backendless.initApp(this, YOUR_APP_ID, YOUR_SECRET_KEY, “v1”);
Backendless.Messaging.registerDevice(“183254839430”, “default”, new AsyncCallback<Void>() {
public void handleResponse(Void aVoid) {
Toast.makeText(MainActivity.this, “Registered”, Toast.LENGTH_LONG).show();
public void handleFault(BackendlessFault backendlessFault) {
Toast.makeText(MainActivity.this, backendlessFault.getMessage(), Toast.LENGTH_LONG).show();
Backendless.Messaging.subscribe( “default”,
new AsyncCallback<List<Message>>() {
public void handleResponse(List<Message> response) {
Toast.makeText(MainActivity.this, “Notification arrived successfully”, Toast.LENGTH_LONG).show();
for (Message message : response) {
String publisherId = message.getPublisherId();
Object data = message.getData();
public void handleFault(BackendlessFault fault) {
Toast.makeText(MainActivity.this, fault.getMessage(), Toast.LENGTH_SHORT).show();
new AsyncCallback<Subscription>()
public void handleResponse( Subscription response )
subscription = response;
public void handleFault( BackendlessFault fault )
Toast.makeText( MainActivity.this, fault.getMessage(), Toast.LENGTH_SHORT ).show();
} [Service to listen to message in background, this is not getting triggered]

public class PushReceiver extends GcmListenerService {
//This method will be called on every new message received
public void onMessageReceived(String from, Bundle data) {
Toast.makeText(getApplicationContext(), “Notification came PushReceiver”, Toast.LENGTH_LONG).show();
//Getting the message from the bundle
String message = data.getString(“message”);
//Displaying a notiffication with the message
//This method is generating a notification and displaying the notification
private void sendNotification(String message) {
Intent intent = new Intent(this, MainActivity.class);
int requestCode = 0;
PendingIntent pendingIntent = PendingIntent.getActivity(this, requestCode, intent, PendingIntent.FLAG_ONE_SHOT);
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder noBuilder = new NotificationCompat.Builder(this)
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,; //0 = ID of notification

<?xml version=“1.0” encoding=“utf-8”?>

<uses-permission android:name=“android.permission.INTERNET”/>
<uses-permission android:name=“android.permission.GET_ACCOUNTS”/>
<uses-permission android:name=“android.permission.WAKE_LOCK”/>
<uses-permission android:name=“”/>
<uses-permission android:name=“feelzdroid.backednlessgcm.permission.C2D_MESSAGE”/>
<permission android:name=“feelzdroid.backednlessgcm.permission.C2D_MESSAGE” android:protectionLevel=“signature”/>


<category android:name=“android.intent.category.LAUNCHER” />


<category android:name=“feelzdroid.backednlessgcm”/>
<service android:name=".PushReceiver" android:exported=“false”>



I’m able to register the device, i will be able to see the ID in the messaging section of backendless.However, i’m not getting any notification when i quit the app. Please tell me where is the mistake.

Hi Ramesh,

This article could be useful for you.



Hi, thank you for your response, i tried all the way, but can you tell me what could be the mistake,

  1. Device is successfully registering
  2. Able to see the device ID in Backendless console
  3. Able to trigger the message & see the increment of message count in backendless console
  4. But message is not delivering to my phone i.e registered device. Here is the glitch.

I’m not sure why i’m facing the issue, i cant see the server logs & even in my GCM server also, i’m not able to see any traffic associated with it.

You should proceed following steps:

Some users of android had problems you have described:


Here is some hints for this case:



Hello, Thank you, that is fine. But i need answer related to Backendless, here i’m not sure how backendless app server communicates with GCM. I’m really unaware that internal implementation. You should be able to guide me where exactly the mistake is, i have posted the whole code in my question. Please have look once.