Add Java class in Manifest



  • 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?



  • 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!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.