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. Android Market reverting to old versions on its own. - VERY VERY BAD.

We have had some issues the last few weeks where the Market when
uploading an APK gives us the message that it uploaded ok (say version
2.0.5) . We go look at the market on the phone a few hours later, and
it is back at 2.0.4). This has happened 2x to us now.. But tonight
something even crazier happened, and I think it is causing customers
to leave negative feedback. I have 2 android phones, one shows our app
on the market at version 2.0.5 and the other at 1.0.10!! What is going
on? these were taken just a few seconds apart. I have rebooted both
phones, and they still both do the same.

Here are links to screen shots. Notice description and feed back are
the SAME, the versions are different.

 [side by side PHOTO]

2. Cursor passing to ResourceCursorAdapter


When I pass a reference of a Cursor to ResourceCursorAdapter, when can
I close that cursor?
How can I tell the ResourceCursorAdapter is done with the cursor and i
can call 'close' method?

If i don't do that, it will cause a cursor leak.

Thank you.


3. Can I dynamically switch Adapter of a Gallery

4. appwidget wictionary cant find words and

5. Measurement of Time

6. REG: Xml to Wbxml using EAS

7. testing/understanding weak and strong pointers