From daa7112642502ecf598a5df2a7b927dd2e1074e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Mon, 1 Aug 2016 17:02:17 +0200 Subject: [PATCH] Sens intent with action and also when back pressed --- src/android/ui/SelectPrinterActivity.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/android/ui/SelectPrinterActivity.java b/src/android/ui/SelectPrinterActivity.java index 18bd7d2..e92fc1d 100644 --- a/src/android/ui/SelectPrinterActivity.java +++ b/src/android/ui/SelectPrinterActivity.java @@ -57,6 +57,12 @@ public final class SelectPrinterActivity extends Activity { public static final String EXTRA_PRINTER_ID = "INTENT_EXTRA_PRINTER_ID"; + /** + * The action of the intent. + */ + public static final String ACTION_SELECT_PRINTER = + "ACTION_SELECT_PRINTER"; + /** * Reference to the main view which lists all discovered printers. */ @@ -99,6 +105,15 @@ public final class SelectPrinterActivity extends Activity { super.onDestroy(); } + /** + * Sent intent with empty result. + */ + @Override + public void onBackPressed() { + onPrinterSelected(null); + super.onBackPressed(); + } + /** * Sends an intent with the specified printer back to the owning activity * and finishes that activity. @@ -110,6 +125,7 @@ public final class SelectPrinterActivity extends Activity { Intent intent = new Intent(); intent.putExtra(EXTRA_PRINTER_ID, printerId); + intent.setAction(ACTION_SELECT_PRINTER); setResult(RESULT_OK, intent); finish();