Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Why Don't We Need Permissions for Qt Applications on Android?
Qt 6.11 is out! See what's new in the release blog

Why Don't We Need Permissions for Qt Applications on Android?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ibrahim
    wrote on last edited by
    #1

    Hi;
    I wrote Android native (Java) code for WebView:

    import android.webkit.WebView;
    ...
    WebView webView = (WebView) findViewById(R.id.webView);
    webView.loadUrl("https://qt.io/");
    ...
    

    We need this permission to run the code:

    <uses-permission android:name="android.permission.INTERNET" />
    

    I wrote same application with Qt 5.x:

    import QtWebView 1.1
    ...
    WebView {
      id: webView
      anchors.fill: parent
      url: "https://qt.io/"
    }
    ...
    

    But we don't need the internet permission to run the Qt application. I'm wondering, why don't we need permissions for Qt applications on Android? Thanks.

    ekkescornerE 1 Reply Last reply
    0
    • I Ibrahim

      Hi;
      I wrote Android native (Java) code for WebView:

      import android.webkit.WebView;
      ...
      WebView webView = (WebView) findViewById(R.id.webView);
      webView.loadUrl("https://qt.io/");
      ...
      

      We need this permission to run the code:

      <uses-permission android:name="android.permission.INTERNET" />
      

      I wrote same application with Qt 5.x:

      import QtWebView 1.1
      ...
      WebView {
        id: webView
        anchors.fill: parent
        url: "https://qt.io/"
      }
      ...
      

      But we don't need the internet permission to run the Qt application. I'm wondering, why don't we need permissions for Qt applications on Android? Thanks.

      ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #2

      @Ibrahim take a look at the generated AndroidManifest inside your build dir
      there you'll see all permissions Qt has inserted

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps

      I 1 Reply Last reply
      2
      • ekkescornerE ekkescorner

        @Ibrahim take a look at the generated AndroidManifest inside your build dir
        there you'll see all permissions Qt has inserted

        I Offline
        I Offline
        Ibrahim
        wrote on last edited by
        #3

        @ekkescorner thanks. I found permissions into build-QtAndroid-Android_for_x86_GCC_4_9_Qt_5_8_0_2f23f9-Debug/android-build/AndroidManifest.xml. Then I removed all WebView components from my project and I removed all permissions from build-QtAndroid-*/android-build/AndroidManifest.xml. But when I built my project, I always see this permissions:

        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        

        Whereas my project doesn't need permissions:

        import QtQuick 2.7
        import QtQuick.Controls 2.0
        import QtQuick.Layouts 1.0
        
        ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
        
          Text {
            id: txt
            anchors.centerIn: parent
            text: qsTr("Hello World!")
          }
        }
        

        How can I remove unnecessary permissions from my project?

        ekkescornerE 1 Reply Last reply
        0
        • I Ibrahim

          @ekkescorner thanks. I found permissions into build-QtAndroid-Android_for_x86_GCC_4_9_Qt_5_8_0_2f23f9-Debug/android-build/AndroidManifest.xml. Then I removed all WebView components from my project and I removed all permissions from build-QtAndroid-*/android-build/AndroidManifest.xml. But when I built my project, I always see this permissions:

          <uses-permission android:name="android.permission.INTERNET" />
          <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
          <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
          

          Whereas my project doesn't need permissions:

          import QtQuick 2.7
          import QtQuick.Controls 2.0
          import QtQuick.Layouts 1.0
          
          ApplicationWindow {
            visible: true
            width: 640
            height: 480
            title: qsTr("Hello World")
          
            Text {
              id: txt
              anchors.centerIn: parent
              text: qsTr("Hello World!")
            }
          }
          

          How can I remove unnecessary permissions from my project?

          ekkescornerE Offline
          ekkescornerE Offline
          ekkescorner
          Qt Champions 2016
          wrote on last edited by ekkescorner
          #4

          @Ibrahim you should copy the templates to your project
          Build Android APK
          copy templates

          this copies the templates inside your project

          in your .pro
          ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
          tells Qt where your android files are living

          go into this folder, open AndroidManifest and change the default behaviour
          all is explained there:

              <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
                   Remove the comment if you do not require these default permissions. -->
              <!-- %%INSERT_PERMISSIONS -->
          

          BTW: you should read the documentation: http://doc.qt.io/qtcreator/creator-deploying-android.html
          scroll down to Editing Manifest Files - there you'll find all the needed informations

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved