Answer the question
In order to leave comments, you need to log in
How to create a LiveWallpaper for Android in Qt?
How to create live wallpapers for android in QtQuick? Since version 5.7 Qt supports services, but these services are simple background applications. I shoveled the file Qt5.7.0\5.7\android_armv7\src\android\java\src\org\qtproject\qt5\android\bindings\QtService.java as best I could, something like this came out:
public class QtWallpaperService extends WallpaperService {
/* тут все скопировано из QtService, но вместо onCreate() -> onCreateEngine() */
@Override
public Engine onCreateEngine() {
Toast.makeText(getApplicationContext(), "onCreateEngine()", Toast.LENGTH_LONG).show(); // ok
return new QtWallpaperEngine(m_loader);
}
private class QtWallpaperEngine extends Engine {
private boolean mVisible = false;
private final Handler mHandler = new Handler();
private QtWallpaperServiceLoader m_loader;
private final Runnable mUpdateDisplay = new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "run()", Toast.LENGTH_LONG).show(); // ничего
m_loader.onCreate();
}
};
private class QtWallpaperEngine extends Engine {
private boolean mVisible = false;
private final Handler mHandler = new Handler();
private QtWallpaperServiceLoader m_loader;
private final Runnable mUpdateDisplay = new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "run()", Toast.LENGTH_LONG).show(); // ничего
m_loader.onCreate();
}
};
public QtWallpaperEngine(QtWallpaperServiceLoader loader) {
super();
Toast.makeText(getApplicationContext(), "QtWallpaperEngine()", Toast.LENGTH_LONG).show(); // ok
m_loader = loader;
}
private void draw() {
Toast.makeText(getApplicationContext(), "draw()", Toast.LENGTH_LONG).show(); // ничего (ну оно и понятно)
m_loader.onCreate();
}
@Override
public void onVisibilityChanged(boolean visible) {
Toast.makeText(getApplicationContext(), "onVisibilityChanged: " + visible, Toast.LENGTH_LONG).show(); // ok onVisibilityChanged: true
m_loader.onCreate();
}
@Override
public void onSurfaceChanged(SurfaceHolder holder,
int format, int width, int height) {
}
@Override
public void onSurfaceDestroyed(SurfaceHolder holder) {
}
@Override
public void onDestroy() {
}
}
}
<!-- ФИНТ vvvvvvvvvvvvvvvvvvvvvvvv -->
<service android:process=":qt" android:name="org.qtproject.qt5.android.bindings.QtWallpaperService"
android:enabled="true"
android:label="Wallpaper Example"
android:permission="android.permission.BIND_WALLPAPER">
<!-- android:process=":qt" is needed to force the service to run on a separate process than the Activity -->
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" >
</action>
</intent-filter>
<meta-data
android:name="android.service.wallpaper" android:value="-- %%INSERT_APP_LIB_NAME%% --"
android:resource="@xml/mywallpaper" >
</meta-data>
<!-- Ministro -->
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Ministro -->
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Deploy Qt libs as part of package -->
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Run with local libs -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<meta-data android:name="android.app.background_running" android:value="true"/>
</service>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question