startActivity() always runs the activity on the main thread. How about just looking at your app in the debugging to see where the threads are stuck?
On Wed, Dec 22, 2010 at 7:11 AM, Schoel <[email protected]> wrote: > I have a function call from a large engine (which I can not change) > which asks the user whether to save or not. Before this function call > returns, I need an answer from the user whether to save. > > There is, as far as I know, no way to start an activity (or show a > dialog) that synchronously returns an answer. Therefore I did like > this (code is not complete but should be enough for understanding): > > int queryUserSave() > { > s_Semaphore.acquire(); > startActivity(QueryUserSaveActivity); > s_Semaphore.acquire(); > s_Semaphore.release(); > return s_nQueryUserSaveResult; > } > > void onQueryUserSaveResult(int aResult) > { > s_nQueryDialingLineResult = aResult; > s_Semaphore.release(); > } > > > The problem is, on the second acquire, the program halts (as intended) > without spawning the QueryUserSaveActivity (not as intended). The idea > was that the QueryUserSaveActivity would be spawned and the second > acquire would block until onQueryUserSaveResult is called. > I've checked the thread id of the thread in which queryUserSave is > called and the thread id in which the QueryUserSaveActivity is started > (if I don't use any semaphores) and they are not the same. I thus > conclude that startActivity starts the activity in another thread (the > UI thread) and therefore shouldn't care about the second acquire call. > I also tried setting the startActivity in its own thread and start > that thread with the same result as above. > Do you have any ideas what I can do to solve this? > > Appriciate any help, > Schoel > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] 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

