当前位置: 首页>>代码示例>>Java>>正文


Java PrintJob类代码示例

本文整理汇总了Java中android.printservice.PrintJob的典型用法代码示例。如果您正苦于以下问题:Java PrintJob类的具体用法?Java PrintJob怎么用?Java PrintJob使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrintJob类属于android.printservice包,在下文中一共展示了PrintJob类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRequestCancelPrintJob

import android.printservice.PrintJob; //导入依赖的package包/类
@Override
protected void onRequestCancelPrintJob(PrintJob printJob) {
    Log.i(LOG_TAG, "#onRequestCancelPrintJob() printJobId: " + printJob.getId());
    if (mHandler.hasMessages(PrintHandler.MSG_HANDLE_PRINT_JOB)) {
        mHandler.removeMessages(PrintHandler.MSG_HANDLE_PRINT_JOB);
        if (printJob.isQueued() || printJob.isStarted()) {
            printJob.cancel();
        }
    } else {
        if (printJob.isQueued() || printJob.isStarted()) {
            printJob.cancel();
        }
    }
}
 
开发者ID:serrexlabs,项目名称:thermal-printer-service,代码行数:15,代码来源:ThermalPrintService.java

示例2: handleHandleQueuedPrintJob

import android.printservice.PrintJob; //导入依赖的package包/类
private void handleHandleQueuedPrintJob(final PrintJob printJob) {
    if (printJob.isQueued()) {
        printJob.start();
    }
    final PrintJobInfo info = printJob.getInfo();
    final File file = new File(getFilesDir(), info.getLabel() + ".pdf");


    InputStream in = null;
    FileOutputStream out = null;

    try {
        in = new FileInputStream(printJob.getDocument().getData().getFileDescriptor());
        out = new FileOutputStream(file);

        byte[] buffer = new byte[1024];
        int read;
        while ((read = in.read(buffer)) != -1) {
            out.write(buffer, 0, read);
        }
        in.close();

        out.flush();
        out.close();


        Intent printPreview = new Intent(this, MainActivity.class);
        printPreview.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        printPreview.putExtra("FILE", file.getPath());
        startActivity(printPreview);

    } catch (IOException ioe) {

    }

}
 
开发者ID:serrexlabs,项目名称:thermal-printer-service,代码行数:37,代码来源:ThermalPrintService.java

示例3: handleMessage

import android.printservice.PrintJob; //导入依赖的package包/类
@Override
public void handleMessage(Message message) {
    switch (message.what) {
        case MSG_HANDLE_PRINT_JOB: {
            PrintJob printJob = (PrintJob) message.obj;
            handleHandleQueuedPrintJob(printJob);
        } break;
    }
}
 
开发者ID:serrexlabs,项目名称:thermal-printer-service,代码行数:10,代码来源:ThermalPrintService.java

示例4: onPrintJobQueued

import android.printservice.PrintJob; //导入依赖的package包/类
@Override
protected void onPrintJobQueued(PrintJob printJob) {
    Message message = mHandler.obtainMessage(PrintHandler.MSG_HANDLE_PRINT_JOB, printJob);
    mHandler.sendMessageDelayed(message, 0);
}
 
开发者ID:serrexlabs,项目名称:thermal-printer-service,代码行数:6,代码来源:ThermalPrintService.java

示例5: onRequestCancelPrintJob

import android.printservice.PrintJob; //导入依赖的package包/类
@Override
protected void onRequestCancelPrintJob(PrintJob printJob) {
    Log.d(TAG, "onRequestCancelPrintJob(printer id = "
            + printJob.getInfo().getPrinterId().getLocalId()
            + ", job id = " + printJob.getId());
}
 
开发者ID:sys1yagi,项目名称:DropboxPrintService,代码行数:7,代码来源:DropboxPrintService.java


注:本文中的android.printservice.PrintJob类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。