Enable QtAndroid::runOnAndroidThread in a Service
Change-Id: I214f5dc70c52011a5e1712ea70f97f8b564fb664 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
parent
cab4d495b2
commit
aebf66d242
@ -243,13 +243,24 @@ public class QtNative
|
||||
}
|
||||
}
|
||||
|
||||
private static void runPendingCppRunnablesOnUiThread()
|
||||
private static void runPendingCppRunnablesOnAndroidThread()
|
||||
{
|
||||
synchronized (m_mainActivityMutex) {
|
||||
if (!m_activityPaused && m_activity != null)
|
||||
m_activity.runOnUiThread(runPendingCppRunnablesRunnable);
|
||||
else
|
||||
runAction(runPendingCppRunnablesRunnable);
|
||||
if (m_activity != null) {
|
||||
if (!m_activityPaused)
|
||||
m_activity.runOnUiThread(runPendingCppRunnablesRunnable);
|
||||
else
|
||||
runAction(runPendingCppRunnablesRunnable);
|
||||
} else {
|
||||
final Looper mainLooper = Looper.getMainLooper();
|
||||
final Thread looperThread = mainLooper.getThread();
|
||||
if (looperThread.equals(Thread.currentThread())) {
|
||||
runPendingCppRunnablesRunnable.run();
|
||||
} else {
|
||||
final Handler handler = new Handler(mainLooper);
|
||||
handler.post(runPendingCppRunnablesRunnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
|
||||
return JNI_ERR;
|
||||
|
||||
g_runPendingCppRunnablesMethodID = env->GetStaticMethodID(jQtNative,
|
||||
"runPendingCppRunnablesOnUiThread",
|
||||
"runPendingCppRunnablesOnAndroidThread",
|
||||
"()V");
|
||||
g_hideSplashScreenMethodID = env->GetStaticMethodID(jQtNative, "hideSplashScreen", "()V");
|
||||
g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
|
||||
|
Loading…
Reference in New Issue
Block a user