pushnotification does not work when application is closed.What should I do for that

I want my push notification to work even if app is not running
manifest:
<?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=“com.google.android.c2dm.permission.RECEIVE”/>
<uses-permission android:name=“com.abhi.dubey.pushdemo.permission.C2D_MESSAGE”/>
<permission android:name=“com.abhi.dubey.pushdemo.permission.C2D_MESSAGE” android:protectionLevel=“signature”/>


<intent-filter>

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

<receiver android:name=“com.backendless.push.BackendlessBroadcastReceiver” android:permission=“com.google.android.c2dm.permission.SEND”>
<intent-filter>


<category android:name=“com.abhi.dubey.pushdemo”/>
</intent-filter>
</receiver>

</manifest>
Java:
package com.abhi.dubey.pushdemo;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import com.backendless.Backendless;
import com.backendless.Messaging;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.exceptions.BackendlessFault;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, “Replace with your own action”, Snackbar.LENGTH_LONG)
.setAction(“Action”, null).show();
}
});
Backendless.initApp(this, “XXXX”, “XXXXXX”, “X”);
// Messaging.DEVICE_ID=“Emulator”;
Backendless.Messaging.registerDevice(“XXXXXX”, new AsyncCallback<Void>() {
@Override
public void handleResponse(Void aVoid) {
Toast.makeText(MainActivity.this, “Registered”, Toast.LENGTH_SHORT).show();
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Toast.makeText(MainActivity.this, “Server reported an error:”+backendlessFault.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

Please watch a recording of the Push Notifications webinar. It walks you through the entire process of setting up, publishing and receiving push notifications.

I did same and the did all what was explained . I am getting the push notification only if app is running. If app is closed I am not getting notification
I am new to android please guide me.

For this you would need to implement android.app.Service, which provides the capability to have a running code for your app, while the app is closed.

Thanks mark

Could you provide an example, I have the same problem