Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QtEmbeddedLoader.java
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4package org.qtproject.qt.android;
5
6import android.app.Activity;
7import android.app.Service;
8import android.content.ComponentName;
9import android.content.Context;
10import android.content.ContextWrapper;
11import android.content.Intent;
12import android.content.pm.PackageManager;
13import android.content.pm.PackageManager.NameNotFoundException;
14import android.os.Build;
15import android.os.Bundle;
16import android.util.DisplayMetrics;
17import android.util.Log;
18import android.view.SurfaceView;
19
20import java.io.File;
21import java.io.FileOutputStream;
22import java.lang.reflect.Field;
23import java.lang.reflect.InvocationTargetException;
24import java.lang.reflect.Method;
25import java.util.ArrayList;
26import java.util.Arrays;
27import java.util.HashMap;
28import java.util.List;
29import java.util.Objects;
30
31import dalvik.system.DexClassLoader;
32import android.content.res.Resources;
33
34class QtEmbeddedLoader extends QtLoader {
35 private static final String TAG = "QtEmbeddedLoader";
36
37 public QtEmbeddedLoader(Context context) {
38 super(new ContextWrapper(context));
39 // TODO Service context handling QTBUG-118874
40 int displayDensity = m_context.getResources().getDisplayMetrics().densityDpi;
41 setEnvironmentVariable("QT_ANDROID_THEME_DISPLAY_DPI", String.valueOf(displayDensity));
42 String stylePath = ExtractStyle.setup(m_context, "minimal", displayDensity);
43 setEnvironmentVariable("ANDROID_STYLE_PATH", stylePath);
44 setEnvironmentVariable("QT_ANDROID_NO_EXIT_CALL", String.valueOf(true));
45 }
46
47 @Override
48 protected void finish() {
49 // Called when loading fails - clear the delegate to make sure we don't hold reference
50 // to the embedding Context
51 QtEmbeddedViewInterfaceFactory.remove((Activity)m_context.getBaseContext());
52 }
53}
static void * context