Thank you Ben.

I think my first problem is I cannot override QtActivity:: onActivityResult

As a learning attempt I should try implementing in a pure java app first.

Thank you for the informative links!

-Ed



On Jul 22, 2015, at 12:44 AM, Ben Lau 
<xben...@gmail.com<mailto:xben...@gmail.com>> wrote:


For passing data from Java to C++,  you may declare a native method in Java and 
register via JNI in C++ side.

Example :

Declare native method
qtandroidexamplecode/QtRunner.java at master · 
benlau/qtandroidexamplecode<https://github.com/benlau/qtandroidexamplecode/blob/master/qtandroidrunner/android/src/com/github/qt/QtRunner.java#L36>

Registration:
qtandroidexamplecode/qtandroidrunner.cpp at master · 
benlau/qtandroidexamplecode<https://github.com/benlau/qtandroidexamplecode/blob/master/qtandroidrunner/qtandroidrunner.cpp#L23>

That is the standard way. However, in case you have problem in coding with JNI, 
you may also consider an alternative method with using 3rd party library:

Communication between C++ and Java without using JNI | Qt 
Forum<http://forum.qt.io/topic/56510/communication-between-c-and-java-without-using-jni>



On 22 July 2015 at 00:35, Edward Sutton 
<edward.sut...@subsite.com<mailto:edward.sut...@subsite.com>> wrote:
I have an activity working that I use to send a firmware update file from 
Android to a Bluetooth device using Android’s support for Object Push File 
“com.android.bluetooth.opp.BluetoothOppLauncherActivity"

Can QtActivity receive a onActivityResult and connect it back to the C++ code 
somehow?  It does not allow me to override it.

http://developer.android.com/training/basics/intents/result.html


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == PICK_CONTACT_REQUEST) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {
            // The user picked a contact.
            // The Intent's data Uri identifies which contact was selected.

            // Do something with the contact here (bigger example below)
        }
    }
}




public class TsrActivity extends QtActivity

{

    private static TsrActivity m_instance;


    public TsrActivity()

    {

        m_instance = this;

    }


    /// Sends firmware file via OBEX OPP

    ///

    /// \remarks user must select matching "TK_0003" from intent screen

    ///

    /// \param[in] absolutePathToFile path to firmware files TK_11.tsu

    /// \param[in] address email body

    public static void sendFile(String absolutePathToFile, String address) {

            try {

                    System.out.println("dbg: sendFile");

                    System.out.println("dbg: absolutePathToFile:" + 
absolutePathToFile);

                    System.out.println("dbg: address:" + address);


                    String intentAction = android.content.Intent.ACTION_SEND;

                    final Intent intent = new Intent(intentAction);

                    intent.setType("application/x-tar");

                    intent.setClassName("com.android.bluetooth",

                                        
"com.android.bluetooth.opp.BluetoothOppLauncherActivity");


                    Uri uriFile = Uri.fromFile(new File(absolutePathToFile));

                    intent.putExtra(Intent.EXTRA_STREAM, uriFile);


                    // title does not display on intent?

                    String title = "Update software";

                    m_instance.startActivity(Intent.createChooser(intent, 
title));


            } catch (Throwable t) {

                System.out.println("dbg: sendFile.exception");


                    Toast.makeText(m_instance, "Request failed clickbutton: " + 
t.toString(),

                                    Toast.LENGTH_LONG).show();

            }

    }


-Ed




This email and any files transmitted with it from The Charles Machine Works, 
Inc. are confidential and intended solely for the use of the individual or 
entity to which they are addressed. If you have received this email in error 
please notify the sender. Our company accepts no liability for the contents of 
this email, or for the consequences of any actions taken on the basis of the 
information provided, unless that information is subsequently confirmed in 
writing. Please note that any views or opinions presented in this email are 
solely those of the author and do not necessarily represent those of the 
company. Finally, the recipient should check this email and any attachments for 
the presence of viruses. The company accepts no liability for any damage caused 
by any virus transmitted by this email.

_______________________________________________
Interest mailing list
Interest@qt-project.org<mailto:Interest@qt-project.org>
http://lists.qt-project.org/mailman/listinfo/interest



This email and any files transmitted with it from The Charles Machine Works, 
Inc. are confidential and intended solely for the use of the individual or 
entity to which they are addressed. If you have received this email in error 
please notify the sender. Our company accepts no liability for the contents of 
this email, or for the consequences of any actions taken on the basis of the 
information provided, unless that information is subsequently confirmed in 
writing. Please note that any views or opinions presented in this email are 
solely those of the author and do not necessarily represent those of the 
company. Finally, the recipient should check this email and any attachments for 
the presence of viruses. The company accepts no liability for any damage caused 
by any virus transmitted by this email.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to