i'm using editing tool arcgis maps.first launch mainactivity , there user may draw drawings on map.and drawing wants list menu in material design navigation drawer, there's item called file browser.here after clicked item goes activity called file browser.after selecting relevant file there want launch mainactivity edited drawings. in mainactivity;
public void onnavigationdraweritemselected(int position) { switch (position) { case 1: { intent intent = new intent(mainactivity.this, filechooser.class); startactivity(intent); break; } default: break; } }
in filechooser activity;
//here selecting relevent file drawings.really here selecting file contains relevent coordinates drawings on map , pass file path mainactivity.map on mainactivity.this activity contains file browser. protected void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); option o = adapter.getitem(position); if (o.getdata().equalsignorecase("folder") || o.getdata().equalsignorecase("parent directory")) { direction = new file(o.getpath()); fill(direction); } else { filepath = o.getpath(); intent intent2 = new intent(filechooser.this, mainactivity.class); //but here want go mainactivity previous drawings not want restart activity. intent2.putextra("path", filepath); startactivity(intent2); } }
so can that? if please me.sory engish :(
mainactivity
should start filechooser
using startactivityforresult()
. filechooser
creates intent
uses return data mainactivity
. pass data mainactivity
, filechooser
needs call setresult()
, finish()
(instead of calling startactivity()
). close filechooser
, call onactivityresult()
in mainactivity
.
edit add code example
in mainactivity
:
public void onnavigationdraweritemselected(int position) { switch (position) { case 1: { intent intent = new intent(mainactivity.this, filechooser.class); startactivityforresult(intent, 1); break; } } } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == 1) { if (resultcode == result_ok) { // "data" intent filechooser sent // can data.getstringextra(...) or whatever // data string filepath = data.getstringextra("path"); } else { // filechooser failed whatever reason } } }
in filechooser
:
protected void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); option o = adapter.getitem(position); if (o.getdata().equalsignorecase("folder") || o.getdata().equalsignorecase("parent directory")) { direction = new file(o.getpath()); fill(direction); } else { filepath = o.getpath(); intent intent2 = new intent(); //but here want go mainactivity previous drawings not want restart activity. // return filepath intent2.putextra("path", filepath); setresult(result_ok, intent2); // close activity return mainactivity finish(); } }
Comments
Post a Comment