Implementing Search filter in Android -
suppose showing list of movies.
you offering filter (as separate activity) (filter window overlayed on top of list of movies (not sure how in android)
now user selects filters in filter screen, , wants apply filter.
the filter data should transfered filter activity previous activity (which shows movie lists).
how can pass data in scenario?
should use kind of event system (such notificationcenter in ios)? or should use form of startactivity
though activity started , waiting.
when want open particular
activity
result in previousactivity
, best practice according me usestartactivityforresult(intent,requestcode)
instead ofstartactivity(intent)
.override following method 1st activity wish receive data
onactivityresult(int requestcode, int resultcode, intent data)
in order result on 1st activity, following code should triggered in 2nd activity
intent resultintent = new intent(); resultintent.putextra("data", yourdata); //make 'yourdata' serializable if pojo setresult(activity.result_ok, resultintent); finish();
after code triggers callback in
onactivityresult()
in 1st activity calledstartactivityforresult()
whateverextars
put. hope helps. gl
Comments
Post a Comment