簡體   English   中英

使用打印機管理器將wifi打印機連接到android設備以編程方式打印PDF

[英]Connect wifi Printer to android device to take PDF print programatically using Printer Manager

我想將我的wifi打印機連接到我的android設備上,並使用打印機管理器進行pdf打印。我在Google上進行了大量搜索,盡管像我這樣有很多問題,但我沒有任何解決方案。請幫忙。謝謝...!

我假設您嘗試使用打印管理器打印自定義文檔。

在您給打印命令的時間出現一個對話框,無限期地顯示“正在搜索打印機”。

  1. 從打印機提供測試文檔打印,然后您將獲得所需的信息以連接到打印機。

  2. 那么您要做的就是從Play商店下載適用於您的打印機的“插件”。

  3. 下載后,您需要打開它並使用您在測試文檔打印中獲得的憑據連接到打印機。

現在嘗試從您的應用程序中打印文檔。

私人void connect(BluetoothDevice device){

    //try to make a "Bond" if possible. Else return
    if (device.getBondState() == BluetoothDevice.BOND_NONE) {
        try {
            createBond(device);
        } catch (Exception e) {
            showToast("Failed to pair device");

            return;
        }
    }

私人void createBond(BluetoothDevice device)引發異常{

    try {
        Class<?> cl = Class.forName("android.bluetooth.BluetoothDevice");
        Class<?>[] par = {};

        Method method = cl.getMethod("createBond", par);

        method.invoke(device);

    } catch (Exception e) {
        e.printStackTrace();

        throw e;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM