Hello fellow programmers,

I am completely stumped on an issue of a 'getIntent()' equivalent for QAndroidJniObject and am hoping I am just overlooking the obvious. Any help or guidance would be greatly appreciated!

Situation:
========

In my Qt project (5.4.2 - Android) I am building an application that launches an external application. This works exactly as expected.

Qt Code:
  1. QAndroidJniObject intent("android/content/Intent","()V");
  2. if ( intent.isValid() )
  3. {
  4. QAndroidJniObject param1 = QAndroidJniObject::fromString("com.mycompany.myapp");
  5. QAndroidJniObject param2 = QAndroidJniObject::fromString("com.mycompany.myapp.mymethod");
  6.  
  7. if ( param1.isValid() && param2.isValid() ) //if ( param1.isValid() && param2.isValid() )
  8. {
  9. intent.callObjectMethod("setClassName","(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;",param1.object<jobject>(),param2.object<jobject>());
  10. activity.callObjectMethod("startActivity","(Landroid/content/Intent;)V",intent.object<jobject>());
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 

The external application is launched and it gets some data (string) and then sends out an intent. (The external application was made with java in eclipse)

Qt Code:
  1. Intent shareIntent = new Intent();
  2. shareIntent.setAction(Intent.ACTION_SEND);
  3. shareIntent.setType("text/plain");
  4. shareIntent.putExtra(Intent.EXTRA_TEXT, dataToSend);
  5. startActivity(shareIntent);
To copy to clipboard, switch view to plain text mode 


Here is where I am at a loss. Concurrently, I build a small test app in eclipse just to be sure I have the logic correct. With the code below it grabs the shared intent without issue and I am able to display the data. However, in Qt I have no luck.

Qt Code:
  1. Intent intent = getIntent();
  2. String action = intent.getAction();
  3. String type = intent.getType();
  4.  
  5. if (Intent.ACTION_SEND.equals(action) && type != null) {
  6. if ("text/plain".equals(type)) {
  7. handleSendText(intent); // Handle text being sent
  8. }
  9. }
  10.  
  11. void handleSendText(Intent intent) {
  12. String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
  13. if (sharedText != null) {
  14. // Update UI to reflect text being shared
  15.  
  16. mTextToShare.setText(sharedText);
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 


I have tried creating a java class within my Qt project, but have only had success calling static methods from within the project itself (i.e. manipulating integers, etc.). If I use the above 'getIntent()' in a java class and try to call it from the Qt side, I receive no errors, but only return empty strings. The code I tried on the Qt side is:

Qt Code:
  1. QAndroidJniObject data = QAndroidJniObject::callStaticObjectMethod<jstring>("com/mycompany/myapp/myclass", "mymethod");
  2. QString myData = data.toString();
To copy to clipboard, switch view to plain text mode 


Additionally, I have edited my AndroidManifest.xml with an intent-filter the same as that test app I build in eclipse as:

Qt Code:
  1. <intent-filter>
  2. <action android:name="android.intent.action.SEND"/>
  3. <category android:name="android.intent.category.DEFAULT"/>
  4. <data android:mimeType="text/plain"/>
  5. </intent-filter>
To copy to clipboard, switch view to plain text mode 


So this is my situation at hand. Ultimately, I would like to be able to be able to get the data and place it in a QString. I have done it without issue in two apps written in java, but can't get it working with Qt. Any help at all would greatly, greatly appreciated. This is my first post so I apologize if I have broken any guidelines. Thank you for looking!!