This is my Code here
Here In my activity I am using Epson SDK to print data form web-view to android activity..
So on Web-veiw Onclick It will start Printer Activity and It will print
What I am trying to do is..... OnClick from Web-view it will Open printer Activity so that it should print and Exit...
So here I have created a Web-view... With the help of JS it sill Open my activity form Web-view (onclick) till now its fine... But I tried to Add print and exit.. onclick but Its not working... Because I need to select language and Printer Model....
How ever in shared_DiscoveryActivity I am adding Printer and saved it in shared prefs... so it will not ask any more... its working
So Here My problem Is that
1) Printer is Asking for Model No and Language So Can Any one suggest me How to Give them Manually instead of Selection here is the Old Code
mPrinter = new Printer(((SpnModelsItem) mSpnSeries.getSelectedItem()).getModelConstant(),
((SpnModelsItem) mSpnLang.getSelectedItem()).getModelConstant(),
mContext);
For this I got these Values at System.out.print
System.out:----- spnSeries -----android.widget.Spinner{24440249 VFED..C. ........ 0,444-466,516 #7f0e007b app:id/spnModel}
System.out: ----- lang -----android.widget.Spinner{1a6c617c VFED..C. ........ 0,604-366,676 #7f0e007d app:id/spnLang}
System.out: ----- printer -----com.epson.epos2.printer.Printer@b8250d6
2) This is the Major Problem Here I am defining Printer In Shared Pinter So In my Code It will Check for Printer On that address
But Here If printer Is not Found What should I do...
Because On webview Printer Will start at Backend.. But App remains in webview So its crashing... Please suggest me on this kind
Update 1
Here I have Added a New File Test_P
this will print in background without showing any info to User OnClick It will start Printing Here My problem is that If the Printer is Offline Or User is not on Same Network App Is Crashing instead of that I tried to Give a Message That Print is not avilable/Conffiged Please try again... but The Text or Alert Is not Showing.
I am Getting This Error If printer is offline or Not Found
FATAL EXCEPTION: main
Process: com.epson.epos2_printer, PID: 15489
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getString(int)' on a null object reference
at com.epson.epos2_printer.ShowMsg.showException(ShowMsg.java:16)
at com.epson.epos2_printer.Test_P.connectPrinter(Test_P.java:173)
at com.epson.epos2_printer.Test_P.printData(Test_P.java:249)
at com.epson.epos2_printer.Test_P.runPrintReceiptSequence(Test_P.java:295)
at com.epson.epos2_printer.Test_P.access$200(Test_P.java:33)
at com.epson.epos2_printer.Test_P$2.run(Test_P.java:128)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5408)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Actually If Printer Not Available it should go to Config printer and Then print again ,,,But I tried to Make a msg But Its crashing Please Help me on this thanks....
On your Android device, download the Epson Print Enabler plug-in from Google Play. Go to Settings on your Android device, select Printing, and enable the Epson plug-in. Connect your Android device to the same wireless network as your product. Now you are ready to print.
once Check the [Epson ePOS SDK for Android User Manual][1]
You Need to Download There Is no Display Option
After that go to
You will see this...
Printer printer = null;
try {
printer = new Printer(Printer.TM_T88, Printer.MODEL_ANK, this);
}
catch (Epos2Exception e) {
//Displays error messages
}
In your Code Just Add this
mPrinter = new Printer(Printer.TM_T88, Printer.MODEL_ANK, this);
Here i have Given TM_T88 it supports Most of the Printer Models... If your Printer model is Specific then Give it... Manually or else Keep above Code
This works fine on all EPSON thermal Printers..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With