<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Hi,</span><div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">
I am working on few Android projects that need the use of native components(e.g WebView). However, the Qt 5.2 do not provide binding of Android's view component and therefore it need to build by our team. </div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">Override the QtActivity class is the most simple method , but it may be a bad idea as it may not compatible for newer version. Moreover, it is not reusable. </div>
<div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">Now, I am trying to refactor the code to make some reusable components . The first product is a class called QtAndroidRunner to execute C++ code on the UI thread.</div>
<div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">The source code with example code:</div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<a href="https://github.com/benlau/qtandroidexamplecode/tree/master/qtandroidrunner" target="_blank">https://github.com/benlau/qtandroidexamplecode/tree/master/qtandroidrunner</a><br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">This example project will create a WebView using native component on top of QtSurface. </div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">
<br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">The solution isn't perfect , it need to be initialized on JNI_onLoad(). As the FindClass function can only resolve custom Java code inside Qt project on JNI_onLoad(). Although QAndroidJinObject is able to resolve custom Java code outside JNI_onLoad(), it has no API to obtain the jclass object to setup native methods.</div>
<div style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></div><div style="font-family:arial,sans-serif;font-size:12.800000190734863px">Therefore, I would like to seek for suggestion from the mailing list. Any comment / suggestion to improve the code is highly welcome.</div>
</div>