i want to start notification when my app goes to minimize with home button etc. (but not with BACK, when user press back, it exits app). I create onPause functions but nottification started also when i push back button :) maybe when back is pressed android start onPause too.
Public void onPause(){
try{
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.city, "Notification Test", System.currentTimeMillis());
Context context = getApplicationContext();
CharSequence contentTitle = "asdf TITLE asdf";
CharSequence contentText = "blah blah";
Intent notificationIntent = new Intent(HomeActivity.this, HomeActivity.class);
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
//auto cancel after select
notification.flags |= Notification.FLAG_AUTO_CANCEL;
PendingIntent contentIntent = PendingIntent.getActivity(HomeActivity.this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1, notification);
}catch(Exception e){}
}
super.onPause();
any idea ? thanks for answer