onActivityResult() does not get results from Sub-SubActivit

Put your problem here if it does not fit any of the other categories.

onActivityResult() does not get results from Sub-SubActivit

Postby emptyonline » Tue Jan 29, 2008 6:30 am

I am unable to get results from a SubActivity that is called 3 levels deep (Activity calls SubActivity1 calls SubActivity2). My SubActivity1 returns null for String data when returning from SubActivity2. Is this possible? I however in Activity can correctly get return data from SubActivity1. I hope I am making sense here.

SubActivity2:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         protected void onPause() {
  2.  
  3.                 super.onPause();
  4.  
  5.                 Log.d(CLASSNAME, "Entered onPause()");
  6.  
  7.                 setResult(2, "test", null);
  8.  
  9.                 finish();
  10.  
  11.         }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


SubActivity1:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private final void callSubActivity2() {
  2.  
  3.                 startSubActivity(new Intent(SubActivity1.this, SubActivity2.class),1);
  4.  
  5.         }
  6.  
  7.         protected void onActivityResult(int requestCode, int resultCode, String data, Bundle extras) {
  8.  
  9.                 super.onActivityResult(requestCode, resultCode, data, extras);
  10.  
  11.                 Log.d(CLASSNAME, "RequestCode=" + requestCode + " Notes text: " + data);
  12.  
  13.         }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Activity:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private final void callSubActivity1() {
  2.  
  3.                 startSubActivity(new Intent(Activity.this, SubActivity1.class),1);
  4.  
  5.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Is this possible?
emptyonline
Freshman
Freshman
 
Posts: 9
Joined: Tue Jan 29, 2008 6:25 am

Top

Postby raquibulbari » Tue Jan 29, 2008 11:49 am

Shimugool
User avatar
raquibulbari
Developer
Developer
 
Posts: 25
Joined: Sun Dec 16, 2007 6:31 am
Location: dhaka,bangladesh

Postby emptyonline » Tue Jan 29, 2008 2:40 pm

Thanks for the reply. But it's not the same usecase. In my case, my second subactivity is still valid and I want it to capture the result from the third activity. Think of it like a wizard interface. I go from one screen to the next, and I want data to flow back and forth

emptyonline
Freshman
Freshman
 
Posts: 9
Joined: Tue Jan 29, 2008 6:25 am

Postby raquibulbari » Tue Jan 29, 2008 2:44 pm

u start subactivity from each of your steps and when rolling back you pass the values, you can do it for any number of activities
Shimugool
User avatar
raquibulbari
Developer
Developer
 
Posts: 25
Joined: Sun Dec 16, 2007 6:31 am
Location: dhaka,bangladesh

Postby raquibulbari » Tue Jan 29, 2008 2:53 pm

add this code in subactivity1

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. protected void onActivityResult(int requestCode, int resultCode, String data, Bundle extras) {
  3.  
  4.                 super.onActivityResult(requestCode, resultCode, data, extras);
  5.  
  6.                 Log.d(CLASSNAME, "RequestCode=" + requestCode + " Notes text: " + data);
  7.  
  8.         }
  9.  
  10.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

in subactivity2
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. protected void onActivityResult(int requestCode, int resultCode, String data, Bundle extras) {
  3.  
  4.                 super.onActivityResult(requestCode, resultCode, data, extras);
  5.  
  6.                 Log.d(CLASSNAME, "RequestCode=" + requestCode + " Notes text: " + data);
  7.  
  8.                 setResult(2, "test", null);
  9.  
  10.                 finish();
  11.  
  12.         }
  13.  
  14.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

in subactivity3
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. setResult(2, "test", null); //change values as required and when u r done with subactivity3
  3.  
  4.                 finish();
  5.  
  6.  
  7.  
  8.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
Shimugool
User avatar
raquibulbari
Developer
Developer
 
Posts: 25
Joined: Sun Dec 16, 2007 6:31 am
Location: dhaka,bangladesh

Postby emptyonline » Thu Jan 31, 2008 7:10 am

Thanks for the tip! I finally got it to work.

I was trying to make this work with the onPause() and the back button. Finally I just implemented with my own "OK" button.

raquibulbari wrote:add this code in subactivity1

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. protected void onActivityResult(int requestCode, int resultCode, String data, Bundle extras) {
  2.                 super.onActivityResult(requestCode, resultCode, data, extras);
  3.                 Log.d(CLASSNAME, "RequestCode=" + requestCode + " Notes text: " + data);
  4.         }
  5.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

in subactivity2
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. protected void onActivityResult(int requestCode, int resultCode, String data, Bundle extras) {
  2.                 super.onActivityResult(requestCode, resultCode, data, extras);
  3.                 Log.d(CLASSNAME, "RequestCode=" + requestCode + " Notes text: " + data);
  4.                 setResult(2, "test", null);
  5.                 finish();
  6.         }
  7.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

in subactivity3
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setResult(2, "test", null); //change values as required and when u r done with subactivity3
  2.                 finish();
  3.  
  4.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
[list]
emptyonline
Freshman
Freshman
 
Posts: 9
Joined: Tue Jan 29, 2008 6:25 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 18 guests