Se puede hacer lo que vos estas buscando, pero se hace desde un servicio "NotificationListenerService" Te dejo un post, esta en ingles, pero es fácil de seguir la implementan del código.
NotificationListenerService
Documentacion Oficial
Aplicación de prueba
En el manifiest tenes que declarar el servicio
<service
android:name="it.gmariotti.android.examples.
notificationlistener.SimpleKitkatNotificationListener"
android:label="@string/service_name"
android:debuggable="true"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter>
<action android:name="android.service.
notification.NotificationListenerService" />
</intent-filter>
El usuario tiene que dar el permiso, en la siguiente ruta: "Settings" -> "Security" -> "Notification access".
Implementación del servicio
public class SimpleKitkatNotificationListener extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Notification mNotification=sbn.getNotification();
if (mNotification!=null){
Bundle extras = mNotification.extras;
Intent intent = new Intent(MainActivity.INTENT_ACTION_NOTIFICATION);
intent.putExtras(mNotification.extras);
sendBroadcast(intent);
}
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
} }
Y en el activity quedaría así
public class MainActivity extends Activity {
protected MyReceiver mReceiver = new MyReceiver();
public static String INTENT_ACTION_NOTIFICATION = "it.gmariotti.notification";
protected TextView title;
protected TextView text;
protected TextView subtext;
protected ImageView largeIcon;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Retrieve ui elements
title = (TextView) findViewById(R.id.nt_title);
text = (TextView) findViewById(R.id.nt_text);
subtext = (TextView) findViewById(R.id.nt_subtext);
largeIcon = (ImageView) findViewById(R.id.nt_largeicon);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_autorize:
Intent intent = new Intent
("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
super.onResume();
if (mReceiver == null) mReceiver = new MyReceiver();
registerReceiver(mReceiver, new IntentFilter(INTENT_ACTION_NOTIFICATION));
}
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(mReceiver);
}
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null) {
Bundle extras = intent.getExtras();
String notificationTitle =
extras.getString(Notification.EXTRA_TITLE);
Bitmap notificationLargeIcon =
((Bitmap) extras.getParcelable(Notification.EXTRA_LARGE_ICON));
CharSequence notificationText =
extras.getCharSequence(Notification.EXTRA_TEXT);
CharSequence notificationSubText =
extras.getCharSequence(Notification.EXTRA_SUB_TEXT);
title.setText(notificationTitle);
text.setText(notificationText);
subtext.setText(notificationSubText);
if (notificationLargeIcon != null) {
largeIcon.setImageBitmap(notificationLargeIcon);
}
}
}
}}
Espero te sirva la respuestas