Fixed bug 2258 - Crash when using Android clipboard
chw The Android clipboard manager methods must be called from the UI thread, otherwise crashes of the dalvikvm happen.
This commit is contained in:
parent
d2671e8a86
commit
2ca1d5c980
2 changed files with 29 additions and 1 deletions
|
@ -277,6 +277,34 @@ public class SDLActivity extends Activity {
|
|||
return mSingleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return result of getSystemService(name) but executed on UI thread.
|
||||
*/
|
||||
public Object getSystemServiceFromUiThread(final String name) {
|
||||
final Object lock = new Object();
|
||||
final Object[] results = new Object[2]; // array for writable variables
|
||||
synchronized (lock) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (lock) {
|
||||
results[0] = getSystemService(name);
|
||||
results[1] = Boolean.TRUE;
|
||||
lock.notify();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (results[1] == null) {
|
||||
try {
|
||||
lock.wait();
|
||||
} catch (InterruptedException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return results[0];
|
||||
}
|
||||
|
||||
static class ShowTextInputTask implements Runnable {
|
||||
/*
|
||||
* This is used to regulate the pan&scan method to have some offset from
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue