[TinyTut] - Passing Data to (Sub)Activities

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Re: [TinyTut] - Passing Data to (Sub)Activities

Postby ZegativeNero » Thu Mar 01, 2012 9:50 pm

Hi Guys,

this is my first post here so i hope i find some help on my problem:

I have one texteditor-activity and a little filebrowser-activity which i can start from the texteditor using intents.
I also can open the files in the texteditor by passing the absolute path back to the editor... No Problems so far...

Now the problem:
The filebrowser has an option that when a folder is clicked, it restarts itself with the path of the clicked folder.
After that happened, and clicking a file, the filebrowser gets closed (as it should), but the editor doesn't get the returnkey anymore.

calling the browser from the editor:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                  String currentdir = basedir.toString();                
  2.                  Intent i = new Intent(EditorActivity.this, Filebrowser.class);
  3.                  i.putExtra("currentdir", currentdir);
  4.                  startActivityForResult(i, REQUEST_CODE);
  5.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


returning the absolute path of a file clicked in filebrowser:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                         Intent intent = new Intent();
  2.                         intent.putExtra("returnKey1", files_array.get(o));
  3.                         setResult(RESULT_OK, intent);
  4.                         finish();
  5.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


restarting the filebrowser after a folder is clicked (after that, nothing gets returned to the editor anymore):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                              Intent intent = new Intent(this, Filebrowser.class);
  2.                              intent.putExtra("currentdir", newdir);
  3.                              startActivityForResult(intent, REQUEST_CODE);
  4.                              finish();
  5.  
Parsed in 0.047 seconds, using GeSHi 1.0.8.4


The editors return method:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.             public void onActivityResult(int requestCode,int resultCode,Intent data) {
  2.                
  3.             if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) {
  4.  
  5.             String returnKey = data.getStringExtra("returnKey1");
  6.  
  7.    //followed by opening & reading the file
  8.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


Thx for any help & Best regards
ZegativeNero
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Mar 01, 2012 9:17 pm

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests