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. Add Java class in Manifest
Forum Update on Monday, May 27th 2025

Add Java class in Manifest

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 1.0k Views
  • 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.
  • E Offline
    E Offline
    Elnur_Ismailzada
    wrote on 16 Apr 2018, 21:06 last edited by
    #1

    Hi!

    I want to add a Java class to my project. But the class does not work. In android studio project this code works.
    My Manifest:

    <manifest package="org.qtproject.example.TestPlayer" ~...~>
        <application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="TestPlayer">
            <activity
                      android:name="org.qtproject.qt5.android.bindings.QtActivity" ~...~>
                      <intent-filter>
                          <action android:name="android.intent.action.MAIN" />
                          <category android:name="android.intent.category.HOME" />
                          <category android:name="android.intent.category.LAUNCHER" />
                          <category android:name="android.intent.category.DEFAULT" />
                      </intent-filter>
    
    		<!-- My new class -->
                      <receiver android:name="org.qtproject.qt5.android.bindings.BootReceiver">
                        <intent-filter >
                            <action android:name=
                                "android.intent.action.BOOT_COMPLETED"/>
                        </intent-filter>
                      </receiver>
    ~...~
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    		
    

    My Java class:

    package org.qtproject.qt5.android.bindings;
    
    ~...~
    
    public class BootReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d("TestPlayer", "onReceive");
            Intent myIntent = new Intent(context, QtActivity.class); // it is right?
            myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(myIntent);
        }
    }
    

    Java class in my project:
    0_1523911868975_d5459f19-20e7-4b7f-827f-7c743656a6dc-image.png

    In general, I want to make a kiosk mode on android. Maybe you know more elegant way?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Elnur_Ismailzada
      wrote on 23 Apr 2018, 22:39 last edited by
      #2

      I create template in Projects->Build Android APK. Here's what I got:
      0_1524522656194_fa956251-4528-4cf6-b54f-38a4f61de349-image.png

      I added the class BootReceiver to the folder src\org\qtproject\qt5\android\bindings. And it worked for me!

      1 Reply Last reply
      3

      • Login

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