Android 19 - No resource found [Fixes #97]

This commit is contained in:
Sebastián Katzer 2016-12-18 13:43:07 +01:00
parent 7a473e7dd6
commit 917df3d6c3
3 changed files with 10 additions and 1 deletions

View File

@ -78,7 +78,6 @@
<activity <activity
android:name="de.appplant.cordova.plugin.printer.ui.SelectPrinterActivity" android:name="de.appplant.cordova.plugin.printer.ui.SelectPrinterActivity"
android:label="Printer" android:label="Printer"
android:theme="@android:style/Theme.Material.Settings"
android:exported="false"> android:exported="false">
</activity> </activity>
</config-file> </config-file>

View File

@ -137,6 +137,10 @@ public abstract class Meta {
int resId; int resId;
resId = res.getIdentifier(name, type, pkgName); resId = res.getIdentifier(name, type, pkgName);
if (resId == 0) {
resId = Resources.getSystem().getIdentifier(name, type, "android");
}
return resId; return resId;
} }
} }

View File

@ -28,6 +28,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.print.PrinterId; import android.print.PrinterId;
import android.print.PrinterInfo; import android.print.PrinterInfo;
@ -85,6 +86,11 @@ public final class SelectPrinterActivity extends Activity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 21) {
setTheme(Meta.getResId(
this, "style", "Theme.Material.Settings"));
}
setContentView(Meta.getResId( setContentView(Meta.getResId(
this, "layout", "select_printer_activity")); this, "layout", "select_printer_activity"));