callback/callback-android — pull request #28 by tmaus (2011-11-18 15:21:45+00:00)
Title: Fixing PluginManager Threading UI Issues

First:
PluginManager open a plain java thread for background processing.
Android however requires an AsynTask in order to provide UI Thread capabilites.
I have replaced the simple Thread implementation by a AsyncTask implementation.

if (runAsync) {
new AsyncTask() {
protected Void doInBackground(Void... voids) {

Second:
Async- processing within the PluginManager always ends up in a thrown Javascript CLASS_NOT_FOUND exception, as the async processing part of the code does not return anything.
This exception results in deletion of the counter javascript callback function within the phonegap.js

I have added

// keep the callback for later usage and return without result (as async)
cr = new PluginResult(PluginResult.Status.NO_RESULT);
cr.setKeepCallback(true);
return cr.getJSONString();

that takes care, that the callback-function is not removed from phonegap.js (PhoneGap.callbacks[callbackId])

I hope I made myself clear ..

My Patch fixes the Facebook Android Plugin ....
If you test my code against it ...
you will know what I did ..

if not .. leave me a mail

maus@pirack.com

Best Regards

Thorsten Maus