startActivityForResult problems

by Geos » Thu, 12 Mar 2009 04:20:10 GMT

Sponsored Links
 Hello All

I've use startActivityForResult as it described in many examples but
it return 0 result code after start new Activity.

In main Activity I use such code for sub activity invocation

                Intent iShowVideo = new Intent(EventHandling.this, 

And such code for getting results.

        protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
                // TODO Auto-generated method stub
                //super.onActivityResult(requestCode, resultCode, data);
                if(requestCode == REQUEST_CODE_SHOW_VIDEO){
                        if(resultCode == RESULT_CANCELED){
                                Toast toast = Toast.makeText(this, 
"onActivityResultCancel: " +
String.valueOf(resultCode), Toast.LENGTH_LONG);
                                Toast toast = Toast.makeText(this, 
"onActivityResult: " +
String.valueOf(resultCode), Toast.LENGTH_LONG);

Here is a part code from ShowVideo activity
        protected void onCreate(Bundle savedInstanceState) {
                // TODO Auto-generated method stub


        Button button = (Button)findViewById(;
        button = (Button)findViewById(;

        //setResult(RESULT_OK, (new Intent()).setAction("Test!"));

    private OnClickListener mOkListener = new OnClickListener()
        public void onClick(View v)
            // To send a result, simply call setResult() before your
            // activity is finished.
            setResult(RESULT_OK, (new Intent()).setAction("Corky!"));

This code should work according many examples. And it should return
RESULT_OK after btnOK clicked but after I click this button it only
closes ShowVideo  Activity.

Please help.

startActivityForResult problems

by droozen » Thu, 12 Mar 2009 08:38:01 GMT

 Not sure if this is your problem, but I do notice you commented out
the super.onActivityResult function in your onActivityResult function.
I don't know all of what the parent method for that function does, but
it's pretty good practice to always call the super method first when
you override a method. It could be doing some setup for you.

I could be way off and that's not what's causing your problem, but
it's a good idea to do it anyway, except for in methods where you know
you shouldn't, like the method for an option item being selected.


Sponsored Links

startActivityForResult problems

by Geos » Thu, 12 Mar 2009 14:48:05 GMT

 I found the problem.
It's a singleInstance application launchMode.


Other Threads

1. How to change the normal behaviour of a listview

Hello Android Developers,

does anyone know how to imitate the behaviour of the iPhone list used
in the cineplexx iPhone app shown on this page:

I refer to the left image, which shows a list with different locations
to choose.

Special about this list is, that everytime a location has been
choosen, the list is adjusted automatically, so that the nearest
location is centered in the blue border. The adjusting process is

Thanks in advance!


2. aplikasi p--no (pic gallery)


Cuman ngingetin kalo bisa kata2 sensitive macam (p--n) di masking, soale
walopun kita bicara dalam konteks yang "normal" tapi mesin pencari kata-kata
di milis ngga pandang bulu.
Jangan sampe milis di bredel karena reply2nya tidak apus buntut dan kata2nya
kebawa terus.

sekedar recehan dari saya.


"Indonesian Android Community [id-android]" 

3. CTS not detecting Zoom2 device

4. Moving the Gallery view to the next image on one swipe in Android?

5. A Free Business Directory with Trading Platform. Add your Company

6. Eclipse + ADT + ant +make: Complex project structure

7. IP Camera + Canvas?