[Interest] [ Android ] QtActivity connect startActivityForResult to onActivityResult to callback C++ code?
Edward Sutton
edward.sutton at subsite.com
Tue Jul 21 18:35:21 CEST 2015
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150721/24231110/attachment.html>
More information about the Interest
mailing list