Getting broadcast messages on Android

  • I've been trying to detect when an application is installed or removed, I added this to my manifest

    <receiver android:name="com.iktwo.utils.PackageChangedReceiver">
    <action android:name="android.intent.action.PACKAGE_ADDED" />
    <action android:name="android.intent.action.PACKAGE_REMOVED" />
    <action android:name="android.intent.action.PACKAGE_CHANGED"/>
    <action android:name="android.intent.action.PACKAGE_REPLACED"/>
    <data android:scheme="package" />

    That works fine, onReceive is executed in my class, but I've been trying to get a signal in Qt, so I was following the help

    void registerNativeMethods() {
    JNINativeMethod methods[] {{"callNativeOne", "(I)V", reinterpret_cast<void *>(fromJavaOne)},
    {"callNativeTwo", "(I)V", reinterpret_cast<void *>(fromJavaTwo)}};

    QAndroidJniObject javaClass("com/iktwo/utils/QPackageManager");
    QAndroidJniEnvironment env;
    jclass objectClass = env->GetObjectClass(javaClass.object<jobject>());
                         sizeof(methods) / sizeof(methods[0]));


    but I get this exception

    @java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()@

    I was looking at how is it implemented for bluetooth in 5.3 but still I can't get it to work, is there something I'm missing or doing wrong? Thanks!

Log in to reply

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