From d27777790ee956c532be1dcefb59332e424bedd2 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 29 Jun 2018 13:51:06 -0700 Subject: Android: add Java class to receive Intents We want to be able to respond to a USB device being plugged in. This simply logs the information we get from the device. Sadly the really useful getProductName and getManufacturerName require API level 21 (so Android 5.0 or newer) and we still have a couple hundred users on 4.1-4.4. Signed-off-by: Dirk Hohndel --- android-mobile/AndroidManifest.xml | 2 +- .../mobile/SubsurfaceMobileActivity.java | 95 ++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java (limited to 'android-mobile') diff --git a/android-mobile/AndroidManifest.xml b/android-mobile/AndroidManifest.xml index 0a591eb99..de4ff68ab 100644 --- a/android-mobile/AndroidManifest.xml +++ b/android-mobile/AndroidManifest.xml @@ -11,7 +11,7 @@ android:label="@string/app_name" android:icon="@drawable/subsurface_mobile_icon" > 20) { + // Log.i(TAG + " onNewIntent manufacturer name", device.getManufacturerName()); + // Log.i(TAG + " onNewIntent product name", device.getProductName()); + // } + Log.i(TAG + " onNewIntent toString", device.toString()); + super.onNewIntent(intent); + setIntent(intent); + // Intent will be processed, if all is initialized and Qt / QML can handle the event + if (isInitialized) { + processIntent(); + } else { + isIntentPending = true; + } + } // onNewIntent + + public void checkPendingIntents(String workingDir) { + isInitialized = true; + Log.i(TAG + " checkPendingIntents", workingDir); + if (isIntentPending) { + isIntentPending = false; + Log.i(TAG + " checkPendingIntents", "checkPendingIntents: true"); + processIntent(); + } else { + Log.i(TAG + " checkPendingIntents", "nothingPending"); + } + } // checkPendingIntents + + + private void processIntent() { + Intent intent = getIntent(); + Log.i(TAG + " processIntent", intent.getAction()); + UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); + Log.i(TAG + " processIntent device name", device.getDeviceName()); + // if (Build.VERSION.SDK_INT > 20) { + // Log.i(TAG + " processIntent manufacturer name", device.getManufacturerName()); + // Log.i(TAG + " processIntent product name", device.getProductName()); + // } + Log.i(TAG + " processIntent toString", device.toString()); + } // processIntent +} -- cgit v1.2.3-70-g09d2