Titan: Why isn't the callback for startActivityForResult happening?

I'm trying to run the IntentCookbook sample app from Forging Titanium (Episode 9).

Code here: https://github.com/appcelerator-developer-relations/Forging-Titanium/tree/master/ep-009/IntentCookbook

Most exaples work fine, but when the startActivityForResult (intent, callback) function is used, the callback is not canceled. Also when doing "Capture and View Image" the app will display in landscape orientation after returning from the camera (I assume because it doesn't realize that the camera material is done and it should return to portrait orientation.)

I am using Titanium sdk 1.8.2 and V8-runtime. I tried this on an emulator (android sdk 2.3.3 and 3.0) and two real devices running 2.3.3 and 2.3.4, but they all exhibit the same behavior.

Can anyone tell me why this is not working for me?

EDIT: When trying to "select and edit a contact" it will be the log output.

I/ActivityManager(   62): Displayed com.appcelerator.IntentCookbook/org.appcelerator.titanium.TiActivity: +350ms
I/ActivityManager(   62): Starting: Intent { act=android.intent.action.PICK typ=vnd.android.cursor.dir/person cmp=com.android.contacts/.ContactsListActivity } from pid 413
I/ContactsListActivity(  194): Called with action: android.intent.action.PICK
I/ActivityManager(   62): Displayed com.android.contacts/.ContactsListActivity: +511ms
W/InputManagerService(   62): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@405efe50 (uid=10006 pid=194)

      

+3


source to share


1 answer


I know the question is old, but if anyone is still facing a similar problem, perhaps my solution might work. My code didn't work when I had it like this:

var activity = Ti.Android.currentActivity;
activity.startActivityForResult(intent, function(e){
    // your code
});

      



But then it worked after I changed it like this:

var activity = $.yourWindowId.getActivity(); // this should be the window you are on
activity.startActivityForResult(intent, function(e){
    // your code
});

      

+1


source







All Articles