android - How can I launch fragment in broadcast receiver -
how can use broadcast receiver start/lunch fragment example : if need start/luanch activity , can use intent :
public void onreceive(final context context, intent intent) { this.context = context; this.intent = intent; try { bundle bundle = intent.getextras(); int messageid = bundle.getint("id"); intent = new intent(context, getalarm.class); intent.putextra("id",messageid); intent.setflags(intent.flag_activity_new_task); context.startactivity(intent); } catch (exception e) { toast.maketext(context, "there error ", toast.length_short) .show(); e.printstacktrace(); } }
but don't know how fragment
you must luanch intent , putextera , sendactivity. can launch fragment activity.
Comments
Post a Comment