The proper way to do this is to provide an int value for requestCode
in startActivity. Then in OnActivityResult you have a
switch(requestCode) and within each case you have a switch for
resultCode. You seem to be confusing requestCode and resultCode.

Your requestCode should probably be something like BUS_ACTIVITY that
you give an int value,
then you have
      bus = new Intent(AndTeste.this, Buscador.class);
      startActivityForResult(bus,BUS_ACTIVITY);
.....
Intent data) {
                // See which child activity is calling us back.
     switch(requestCode){
          case BUS_ACTIVITY:
                switch (resultCode) {
                   case RESULT_OK:
                        setTitle("Result Ok");
                   default:
                        break;
                }
            break;
        }

or something along those lines. I think there's plenty of examples in
the api demos.



On Nov 5, 11:39 am, Prestes <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a problem with onActivityResult. My class Activity can not
> return a result for this method.
>
> My class A
> [syntax="java"]
> public class ClassTestA {
>         private Button btOk;
>         private Intent bus;
>
>         /** Called when the activity is first created. */
>         @Override
>         public void onCreate(Bundle savedInstanceState) {
>                 super.onCreate(savedInstanceState);
>                 setContentView(R.layout.main);
>
>                 btOk = (Button) findViewById(R.id.btTeste);
>                 bus = new Intent(AndTeste.this, Buscador.class);
>
>                 btOk.setOnClickListener(new OnClickListener() {
>
>                         public void onClick(View v) {
>                                 bus = new Intent(AndTeste.this, 
> Buscador.class);
>                                 startActivityForResult(bus, RESULT_OK);
>                         }
>
>                 });
>         }
>
>         // Listen for results.
>         protected void onActivityResult(int requestCode, int resultCode,
> Intent data) {
>                 // See which child activity is calling us back.
>                 switch (resultCode) {
>                    case RESULT_OK:
>                         setTitle("Result Ok");
>                    default:
>                         break;
>                 }
>         }}
>
> [/syntax]
>
> Class B
> [syntax="java"]
> public class ClassB {
>         private Button btBus;
>         private EditText end;
>         private Geocoder buscador;
>         private ListView list;
>
>         /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.buscador);
>
>         btBus = (Button) findViewById(R.id.btBuscar);
>         end = (EditText) findViewById(R.id.tiEnd);
>         buscador = new Geocoder(this);
>         list = (ListView) findViewById(R.id.listEnd);
>
>         btBus.setOnClickListener(mCorkyListener);
>     }
>
>     private OnClickListener mCorkyListener = new OnClickListener() {
>         public void onClick(View v) {
>             setResult(RESULT_OK);
>             finish();
>         }
>     };}
>
> [/syntax]
>
> Manifest.xml
> [syntax="xml"]
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android";
>       package="com.maps"
>       android:versionCode="1"
>       android:versionName="1.0.0">
>
>     <application android:icon="@drawable/icon"
> android:label="testeando tudo">
>         <activity android:name=".ClassA" android:label="Testeando a
> And">
>             <intent-filter>
>                 <action android:name="android.intent.action.MAIN" />
>                 <category
> android:name="android.intent.category.LAUNCHER" />
>             </intent-filter>
>         </activity>
>
>         <activity android:name=".ClassB" android:label="TESTEANDO">
>             <intent-filter>
>                 <action android:name="android.intent.action.VIEW" />
>                 <category
> android:name="android.intent.category.DEFAULT" />
>             </intent-filter>
>         </activity>
>     </application>
> </manifest>
> [/syntax]
> My class B to return to class A, but o method onActivityResult is not
> called.
> Someone can help me ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to