[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);
Parsed in 0.064 seconds, using GeSHi

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();
Parsed in 0.077 seconds, using GeSHi

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();
Parsed in 0.096 seconds, using GeSHi

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

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


Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest