title: Create never ending background service for notification
body: <p>i have to create an android application which gives a notification when new message is receiving even if the app is not working.     i am using firebase database.   i wrote code for firebase datasnapshot but it only working when app is working i need to run this code if the app is not working.   </p>
  
  <pre><code>        Mref=new Firebase("https://iyutue-30s49.firebaseio.com/");
      Mref.addChildEventListener(new ChildEventListener() {
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String s) {
  
              String value=dataSnapshot.getValue(String.class);
              myDb.GetAllData();
              String idd= String.valueOf(myDb.id);
              if (value.equals(idd)==true){
                  NotificationCompat.Builder builder=new NotificationCompat.Builder(getApplicationContext());
                  builder.setSmallIcon(R.drawable.ic_tab_profile);
                  builder.setContentTitle("plaese").setContentText("jijo");
                  Intent intent =new Intent(getApplicationContext(),MainActivity.class);
                  TaskStackBuilder stackBuilder=TaskStackBuilder.create(getApplicationContext());
                  stackBuilder.addParentStack(MainActivity.this);
                  stackBuilder.addNextIntent(intent);
                  PendingIntent pendingIntent=stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
                  builder.setContentIntent(pendingIntent);
                  NotificationManager NM=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
                  NM.notify(0,builder.build());
              }
          }
  
          @Override
          public void onChildChanged(DataSnapshot dataSnapshot, String s) {
  
          }
  
          @Override
          public void onChildRemoved(DataSnapshot dataSnapshot) {
  
          }
  
          @Override
          public void onChildMoved(DataSnapshot dataSnapshot, String s) {
  
          }
  
          @Override
          public void onCancelled(FirebaseError firebaseError) {
  
          }
      });
  </code></pre>
  
  <p>i need to execute this code in background when app is not working also please help me thanks in advnace</p>