I need a print a receipt from a receipt printer(network printer) via my android application which is developed by 4.2 version. is Android 4.2 support printing from the network printer? can any one please point me to a correct tutorial. Thanks
Asked
Active
Viewed 1,603 times
0
-
are you fix your problem? i need solution for that help me plz – Karthi Mar 06 '17 at 11:34
1 Answers
0
device connected to a network will communicate via their IP and Ports / sockets.
try
{
Socket sock = new Socket("IP", port);
PrintWriter oStream = new PrintWriter(sock.getOutputStream());
oStream.println("");
oStream.println("");
oStream.close();
sock.close();
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
how to print :
private void doPrint() {
PrintManager printManager = (PrintManager) getActivity().getSystemService(Context.PRINT_SERVICE);
printManager.print("My document", new CustomPrintDocumentAdapter(getActivity()), null);
}
where CustomPrintDocumentAdapter extendsPrintDocumentAdapter
and more info about prnting Android Devlprs
more details Refer.

Community
- 1
- 1

Manish Goswami
- 863
- 10
- 27