Fix broken interfaces with newest Android versions
This commit is contained in:
parent
bf43a8026c
commit
ce5ace90b3
@ -22,6 +22,7 @@
|
|||||||
package de.appplant.cordova.plugin.printer.ext;
|
package de.appplant.cordova.plugin.printer.ext;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.print.PrintJob;
|
import android.print.PrintJob;
|
||||||
import android.print.PrintJobId;
|
import android.print.PrintJobId;
|
||||||
|
|
||||||
@ -107,8 +108,18 @@ public final class PrintManager {
|
|||||||
* @return The found service list or an empty list.
|
* @return The found service list or an empty list.
|
||||||
*/
|
*/
|
||||||
public final List<PrintServiceInfo> getInstalledPrintServices () {
|
public final List<PrintServiceInfo> getInstalledPrintServices () {
|
||||||
List printers = (List) Meta.invokeMethod(getInstance(),
|
List printers;
|
||||||
"getInstalledPrintServices");
|
|
||||||
|
if (Build.VERSION.SDK_INT < 24) {
|
||||||
|
printers = (List) Meta.invokeMethod(getInstance(),
|
||||||
|
"getInstalledPrintServices");
|
||||||
|
} else {
|
||||||
|
Method getPrintServicesMethod = Meta.getMethod(
|
||||||
|
getInstance().getClass(), "getPrintServices", int.class);
|
||||||
|
|
||||||
|
printers = (List) Meta.invokeMethod(getInstance(),
|
||||||
|
getPrintServicesMethod, 3);
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<PrintServiceInfo> services =
|
ArrayList<PrintServiceInfo> services =
|
||||||
new ArrayList<PrintServiceInfo>();
|
new ArrayList<PrintServiceInfo>();
|
||||||
@ -129,8 +140,18 @@ public final class PrintManager {
|
|||||||
* @return The found service list or an empty list.
|
* @return The found service list or an empty list.
|
||||||
*/
|
*/
|
||||||
public final List<PrintServiceInfo> getEnabledPrintServices () {
|
public final List<PrintServiceInfo> getEnabledPrintServices () {
|
||||||
List printers = (List) Meta.invokeMethod(getInstance(),
|
List printers;
|
||||||
"getEnabledPrintServices");
|
|
||||||
|
if (Build.VERSION.SDK_INT < 24) {
|
||||||
|
printers = (List) Meta.invokeMethod(getInstance(),
|
||||||
|
"getEnabledPrintServices");
|
||||||
|
} else {
|
||||||
|
Method getPrintServicesMethod = Meta.getMethod(
|
||||||
|
getInstance().getClass(), "getPrintServices", int.class);
|
||||||
|
|
||||||
|
printers = (List) Meta.invokeMethod(getInstance(),
|
||||||
|
getPrintServicesMethod, 1);
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<PrintServiceInfo> services =
|
ArrayList<PrintServiceInfo> services =
|
||||||
new ArrayList<PrintServiceInfo>();
|
new ArrayList<PrintServiceInfo>();
|
||||||
|
Loading…
Reference in New Issue
Block a user