android - TabActivity pass extras to child intents -
i have 3 activities:
activity a - displays list of data website. activity can perform action add list (activity b).
activity b - activity adds data website. upon successful completion activity need tell activity refresh list.
activity t - tabhost contains activity a.
my problem is:
activity b needs tell activity refresh, intent must activity t, since want tabhost display activity a.
//activityb.class intent myintent = new intent(v.getcontext(), activityt.class); myintent.putextra("target", "activitya"); myintent.putextra("refreshdata", true); startactivityforresult(myintent, 0); i thought use tabhost intermediary , pass extras through activity if set, so:
//activityt.class bundle extras = getintent().getextras(); // create intent launch activity tab (to reused) intent = new intent().setclass(this, activitya.class); // check see if want pass our bundle through activity if (extras != null && extras.getstring("target").equals("activitya")) { intent.putextras(extras); } // initialize tabspec each tab , add tabhost spec = tabhost.newtabspec("tab1").setindicator("tab1", res.getdrawable(r.drawable.ic_tab_tab1)).setcontent(intent); tabhost.addtab(spec); this works great, except when change tabs different tab , change back, extras passed through yet again, , again - causes tab refresh data every time, though i'm no longer coming activity b. because tabactivity doesn't recreated on tab change , therefore extras passed through child intents.
so, how can tell activity refresh activity b, still tabhost show up?
i ended brute forcing problem , copying tabhost, tabactivity, , tabwidget code , customizing needs solve problem. it's not i'm proud of, did trick.
it turned out useful there few minor other tweaks made make easier other things.
Comments
Post a Comment