// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
\page porting-to-android.html
\title Porting to Android
\brief Provides instructions to port your existing Qt application to Android.
\ingroup androidplatform
\previouspage android-building.html
\nextpage examples-android.html

Most Qt applications should be portable to Android with ease, unless they
depend on a specific hardware or software feature not supported by Android.
If your application is not using any such feature, deployment is the only step
that might demands some changes to your application.

\include porting-notes.qdocinc using resources

The other approach is to deploy the resources into the package's \c{assets}
directory. It is the best option if you want to achieve better
interoperability with the Android APIs. You can access all resources in the
directory using the "assets:" prefix. Unlike qrc, this approach is Android
specific, not a cross-platform solution.

To use the "assets:" approach, for example, add the following lines into the
\c {.pro} file:

\badcode
android {
    assets.files = images/happy.png
    assets.path = /assets/images/
    INSTALLS += assets
}
\endcode

Then you can access that image asset from C++ as follows:

\code
QImage image("assets:/images/happy.png");
\endcode

The following step-by-step instructions guide you to port an existing Qt Quick
application to Android using the qrc approach:

\list 1
    \li Open your project in Qt Creator and select an Android kit. For more
        information, see \l{Qt Creator: Configuring Projects}{Configuring Projects in Qt Creator}.
    \li Identify all the resources used by your application and add them to one
        or more qrc files. Qt Creator updates your qmake project file with the
        "RESOURCES" variable listing the qrc files you added.
    \li To load or refer to the resources in the qrc file from your C++ code,
        use the "qrc:" scheme followed by the absolute URL. For example, to
        load the \c{main.qml} file from \c{resources.qrc}, you can use the
        following C++ code:

        \code
        QQuickView viewer;
        viewer.setSource(QUrl("qrc:/qml/main.qml"));
        viewer.show();
        \endcode

        \note QML documents can refer to the contents in qrc files using the
        relative path to the document. Such references do not require the
        "\c{qrc:}" or "\c{:/}" prefix.
    \li Deploy your application to a device or AVD. For more information, see
        \l {Qt Creator: Deploying Applications to Android Devices}.
\endlist

\note Qt Quick Controls will use the \l{Material Style}{Material Style} if the
target device is running Android 3.0 (API 11) or later. The application should
function normally on devices with Android versions earlier than v3.0, but
without native style for controls.
*/
