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.

  1. when want open particular activity result in previous activity, best practice according me use startactivityforresult(intent,requestcode) instead of startactivity(intent).

  2. override following method 1st activity wish receive data onactivityresult(int requestcode, int resultcode, intent data)

  3. 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(); 
  4. after code triggers callback in onactivityresult() in 1st activity called startactivityforresult() whatever extars put. hope helps. gl


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -