我尝试将心爱的代码转换为nativescript但我是新的我不知道这个请告诉我如何将android代码转换为nativescript ...
private void createWebPrintJob() {
// Get a PrintManager instance
PrintManager printManager = (PrintManager)
getSystemService(Context.PRINT_SERVICE);
// Get a print adapter instance
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
// Create a print job with name and adapter instance
String jobName = getString(R.string.app_name) + " Document";
PrintJob printJob = printManager.print(jobName, printAdapter,
new PrintAttributes.Builder().build());
// Save the job object for later status checking
// mPrintJobs.add(printJob);
}
答案 0 :(得分:1)
可能是这样的,
var application = require('application');
var utils = require('utils/utils');
function createWebPrintJob() {
var printManager = application.android.context
.getSystemService(android.content.Context.PRINT_SERVICE);
var printAdapter = webView.createPrintDocumentAdapter();
var jobName = getString(utils.ad.getStringId("app_name")) + " Document";
var printJob = printManager.print(jobName, printAdapter, new namespace.to.PrintAttributes.Builder().build());
mPrintJobs.add(printJob);
}
以上只是puedo代码,结束了它的JavaScript没什么特别的。