isServiceAvailable on Android did not return a list of available printing apps (fix for #6)

This commit is contained in:
Sebastián Katzer 2014-02-28 17:10:07 +01:00
parent 847b91053f
commit 032b2f5611
3 changed files with 12 additions and 5 deletions

View File

@ -25,6 +25,9 @@ cordova plugin rm de.appplant.cordova.plugin.printer
``` ```
## Release Notes ## Release Notes
#### Version 0.5.2 (not yet released)
- [bugfix:] `isServiceAvailable` on Android did not return a list of available printing apps.
#### Version 0.5.1 (15.12.2013) #### Version 0.5.1 (15.12.2013)
- Removed Android KitKat support *(See kitkat branch)* - Removed Android KitKat support *(See kitkat branch)*

View File

@ -27,7 +27,6 @@
<!-- ios --> <!-- ios -->
<platform name="ios"> <platform name="ios">
<config-file target="config.xml" parent="/*"> <config-file target="config.xml" parent="/*">
<feature name="Printer"> <feature name="Printer">
<param name="ios-package" value="APPPrinter"/> <param name="ios-package" value="APPPrinter"/>
@ -36,7 +35,6 @@
<header-file src="src/ios/APPPrinter.h" /> <header-file src="src/ios/APPPrinter.h" />
<source-file src="src/ios/APPPrinter.m" /> <source-file src="src/ios/APPPrinter.m" />
</platform> </platform>
<!-- android --> <!-- android -->

View File

@ -108,9 +108,15 @@ public class Printer extends CordovaPlugin {
* Überprüft, ob ein Drucker zur Verfügung steht. * Überprüft, ob ein Drucker zur Verfügung steht.
*/ */
private void isServiceAvailable (CallbackContext ctx) { private void isServiceAvailable (CallbackContext ctx) {
JSONArray appIds = this.getInstalledAppIds(); JSONArray appIds = this.getInstalledAppIds();
Boolean available = appIds.length() > 0; Boolean available = appIds.length() > 0;
PluginResult result = new PluginResult(PluginResult.Status.OK, available); JSONArray args = new JSONArray();
PluginResult result;
args.put(available);
args.put(appIds);
result = new PluginResult(PluginResult.Status.OK, args);
ctx.sendPluginResult(result); ctx.sendPluginResult(result);
} }