Different android version bug -


i've got simple app status bar icon. when user minimize app, status bar icon appear. when user click on icon, app should resume , continue job. i've tested on android 2.3.4 , works on 4.0 android version app not resuming , continue job open new version of app. how make universal noticifaction code , don't worry of android version?

public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_jajko);      text = (textview) findviewbyid(r.id.tvtime);     play = (button) findviewbyid(r.id.butstart);     miekko = (button) findviewbyid(r.id.butmiekko);     srednio = (button) findviewbyid(r.id.butsrednio);     twardo = (button) findviewbyid(r.id.buttwardo);      miekko.setonclicklistener(this);     srednio.setonclicklistener(this);     twardo.setonclicklistener(this);     play.setonclicklistener(this);      mp = mediaplayer.create(jajko.this, r.raw.alarm);      shownotification(this);  }  public static void shownotification(context context) {     final intent result_intent = new intent(context, jajko.class);      result_intent.setflags(intent.flag_activity_clear_top             | intent.flag_activity_single_top);      taskstackbuilder stack_builder = taskstackbuilder.create(context);     stack_builder.addparentstack(jajko.class);     stack_builder.addnextintent(result_intent);      pendingintent pending_intent = stack_builder.getpendingintent(0,             pendingintent.flag_update_current);      android.support.v4.app.notificationcompat.builder builder = new android.support.v4.app.notificationcompat.builder(             context);      resources res = context.getresources();     builder.setcontentintent(pending_intent)             .setsmallicon(r.drawable.icon)             .setlargeicon(                     bitmapfactory.decoderesource(res, r.drawable.icon))             .setticker("egg timer").setwhen(system.currenttimemillis())             .setautocancel(false).setcontenttitle("egg timer")             .setcontentinfo("").setcontenttext("");     notification n = builder.build();     n.flags = notification.flag_ongoing_event;      notificationmanager = (notificationmanager) context             .getsystemservice(context.notification_service);     notificationmanager.notify(notif_id, n); } 

the documentation taskstackbuilder says behaves differently on pre- , post-3.0 android. haven't used pending intent, i'm not sure expect that.

try removing 3 lines stack builder, , change pending intent line this:

pendingintent pending_intent = pendingintent.getactivity(getbasecontext(),      0, result_intent, pendingintent.flag_update_current); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -