How to sub-class the Google-Cloud-Messaging API in Qt

  • I have been following the docs for implementing the GCM service from Google. I have referenced the library through the command line tool from Android and i have created the AndroidManifest.xml file. So now I have gotten to the point where i need to implement the library into my code in Qt using c++.

    But looking at these docs I get a little confused:

    I don't know how import the library so i can use it. Do i need some kind of "#include" statement?

    Also, i am not sure what other information you guys will need in order to help me with this so I will explain the steps i took to get to this point.


    1. Copy the library project at <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/ to the location where you maintain your Android app projects.

    I copied the /google-play-services_lib folder to my QtProjects folder where all my projects are.

    1. i used the command line tool to reference the google API using target 2:
      android update project --target 2 --path C:\Users\01222_000\QtProjects\app1 --library C:\Users\01222_000\QtProjects\google-play-services_lib

    2. i created the AndroidManifest.xml through Qt and added all the necesary lines per the docs

    <?xml version="1.0"?>
    <manifest package="org.qtproject.example" xmlns:android="" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
    	<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.GET_ACCOUNTS" />
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <uses-permission android:name="" />
    	<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
            android:protectionLevel="signature" />
        <uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
        <application android:hardwareAccelerated="true" android:name="" android:label="-- %%INSERT_APP_NAME%% --">
                android:permission="" >
                    <action android:name="" />
                    <category android:name="com.example.gcm" />
            <service android:name=".GcmIntentService" />
            <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                <meta-data android:name="" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
                <meta-data android:name="" android:resource="@array/qt_sources"/>
                <meta-data android:name="" android:value="default"/>
                <meta-data android:name="" android:resource="@array/qt_libs"/>
                <meta-data android:name="" android:resource="@array/bundled_libs"/>
                <!-- Deploy Qt libs as part of package -->
                <meta-data android:name="" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
                <meta-data android:name="" android:resource="@array/bundled_in_lib"/>
                <meta-data android:name="" android:resource="@array/bundled_in_assets"/>
                <!-- Run with local libs -->
                <meta-data android:name="" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
                <meta-data android:name="" android:value="/data/local/tmp/qt/"/>
                <meta-data android:name="" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
                <meta-data android:name="" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
                <meta-data android:name="" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
                <!--  Messages maps -->
                <meta-data android:value="@string/ministro_not_found_msg" android:name=""/>
                <meta-data android:value="@string/ministro_needed_msg" android:name=""/>
                <meta-data android:value="@string/fatal_error_msg" android:name=""/>
                <!--  Messages maps -->
                <!-- Splash screen -->
                <meta-data android:name="" android:resource="@drawable/logo"/>
                <!-- Splash screen -->
                <!-- Background running -->
                <!-- Warning: changing this value to true may cause unexpected crashes if the
                              application still try to draw after
                              signal is sent! -->
                <meta-data android:name="" android:value="false"/>
                <!-- Background running -->
        <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/>
        <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
        <!-- 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 -->
        <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
             Remove the comment if you do not require these default features. -->
        <!-- %%INSERT_FEATURES -->

    after all that I should be able to call the API as is described in the docs. But it doesn't work.
    I am probably missing something and I would be really glad if someone could point out to me what it is that I am missing.

    Sorry for the long post by the way and thanks in advance.

  • Lifetime Qt Champion


    AFAIK, that's a JAVA API so you would need to take a look at Qt's JNI helpers

    Hope it helps

Log in to reply

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