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. Getting broadcast messages on Android

Getting broadcast messages on Android

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 1.2k 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
    Iktwo
    wrote on last edited by
    #1

    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">
    <intent-filter>
    <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" />
    </intent-filter>
    </receiver>
    @

    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>());
    env->RegisterNatives(objectClass,
                         methods,
                         sizeof(methods) / sizeof(methods[0]));
    env->DeleteLocalRef(objectClass);
    

    }
    @

    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!

    1 Reply Last reply
    0

    • Login

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