本文整理汇总了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();
}
}
}
示例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) {
}
}
示例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;
}
}
示例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);
}
示例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());
}