Calling Intent from Two Locations

by Mark Robinton » Sat, 01 Nov 2008 06:27:44 GMT


Sponsored Links
 Hi,

I am trying to call an intent to select someone from the contactlist
from 2 different places in my program.

In one activity class (my main one) I call:

                Intent i=new Intent(Intent.ACTION_PICK,
                Uri.parse("content://contacts/people"));
                startActivityForResult(i, PICK_REQUEST);


and I am able to catch the result of PICK_REQUEST in my
onActivityResult function, no problem.

When I try calling the same intent within another class, it still
tries to catch it in the
onActivityResult of the main class, not in the onActivityResult i
implemented in the 2nd class.

What am I doing wrong so I don't jump out of my other class (where
there's private data I want to access once I am done getting the
contact info).

Thanks,
Mark



--~--~---------~--~----~------------~-------~--~----~



Calling Intent from Two Locations

by Mark Murphy » Sat, 01 Nov 2008 08:23:38 GMT


 


Is the second class an activity? If not, there's your problem.

If the second class is an activity, I would expect the callback to match 
where startActivityForResult lies. You're not calling 
startActivityForResult in some inner class that gets passed around by 
any chance?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 1.3 Published!

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Issue with launching second one

Hi,

I am trying to write a simple multiple activity application - each of which
has a xml layout file (containing a button)
On the button click, the need to switch between the activities.

My onClick() looks like this

{
        Intent myIntent = new Intent("Multi2");
        Activity act2 = new MultipleActivity();
        act2.startActivity(myIntent);
}

And I have exact replica of code in my second activity as well.

However, when I click on my button, it freezes. Sometimes, there is a force
close warning.

What am I doing wrong?

Regards,
UE.

-- 

2. Randomly generate sound from onClick and onShake events?




You have an array, yes? You know the length, right? So generate a random
number between 0 and length of array, and choose that time. That's it.



I have no idea what this means.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 

3. Power-loss semantics of SQlite on Android

4. Multiple Notifications - PendingIntents with different data?

5. Force Close when trying to use getApplication()

6. Android market clearly has to be full of piracy...oh well what can you do

7. getting R.String Value using different class