Note that there are some explanatory texts on larger screens.

plurals
  1. POShow status bar notification even after application is killed in Android
    primarykey
    data
    text
    <p>I have to make a different kind of notification in my application. The notifications should be shown even if the application is killed from the task manager. The notifications should be stacked one after the another. The existing notification code which I am using is given below.</p> <p>This is the class for creating the notification:</p> <pre><code>public class TimeAlarm extends BroadcastReceiver { NotificationManager nm; @Override public void onReceive(Context context, Intent intent) { nm = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); CharSequence from = "Scheduled Training"; CharSequence message = "Please attend the scheduled training"; PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0); Notification notif = new Notification(R.drawable.ic_launcher, "Scheduled Training", System.currentTimeMillis()); notif.setLatestEventInfo(context, from, message, contentIntent); nm.notify(1, notif); } } </code></pre> <p>This is the code I am using in the activity to create the notifications:</p> <pre><code> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); duration=(EditText)findViewById(R.id.duration_editText); dateAndTimeLabel=(TextView)findViewById(R.id.timeTxt); updateLabel(); updateNotification(); am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // On Click Confirm confirm=(ImageView)findViewById(R.id.confirm_imageView); confirm.setOnClickListener(new OnClickListener() { public void onClick(View v) { getDateTime(); count++; setOneTimeAlarm(); } }); } public void setOneTimeAlarm() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, 0); Intent intent = new Intent(this, TimeAlarm.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent,count); am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent); } void updateNotification() { hour= dateAndTime.get(Calendar.HOUR_OF_DAY); minute=dateAndTime.get(Calendar.MINUTE); } </code></pre> <p>This is not helping me achieve my goal. What should I do? I want to create kind of notification you can find in Ice Age village game.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload