Alibabacloud.com offers a wide variety of articles about print from android to network printer, easily find your print from android to network printer information here online.
Due to the needs of a project, I studied the network communication mode of android, which is similar to that of the java platform!
The android platform also provides a lot of APIS for developers to use. Please refer to the figure below:
First, we will introduce the communication through the http packet tool in two ways: get and post. The difference between the
getInputStream), the program will secretly (implicitly) perform the connection。 Once the connection is available, access to resources such as execution getInputStream () and, for Httpurlconnect, Conn. Getresponsecode () ==200 to determine if the server returned the correct answer code to indicate that the request was accepted. In URLConnection, there is a domain Boolean connected, and a value of TRUE indicates that a connection has been established to the specified URL, and false is not. Connec
Create a new class to inherit Broadcastreceiver, to receive broadcasts, and to handle them accordingly.Class Netchangereceiver extends Broadcastreceiver {@Override public void onreceive (context context, Intent Intent){String action = intent.getaction ();if (Action.equals (connectivitymanager.connectivity_action)) {System.out.println ("Network status change");}else if (action.equals (ethernetmanager.ethernet_state_changed_action)) {System.out.println
It is mainly used to check whether there is a network. If not, set the network in wifi...
The following is the main code:
Private void checkNetWorkInfo () {if (! Tools. isNetworkAvailable (this) {new AlertDialog. Builder (this). setTitle ("prompt! "). SetIcon (android. r. drawable. ic_dialog_info ). setMessage ("You have not enabled the
request management class, specifically for managing requests. There is a request queue, which is then instantiated in the initialization method.private static Requestqueue Mrequestqueue;public Requestmanager () {//TODO auto-generated constructor stub} public static void Initvolley (Context context) {Mrequestqueue = Volley.newrequestqueue (context);}
( 2 ) and then write the picture requestRetrieves an image specified by the URL, displays it in the UI. Request = new Imagerequest (URL, ne
DataOutputStream (S.getoutputstream ()); DIN = new DataInputStream (S.getinputstream ());} catch (Exception e) {//catch exception e.printstacktrace ();//Print Exception}2, this still does not, finally inStackOverflow found the answer,also needOpen Strictmode in OnCreate Strictmode.setthreadpolicy (New StrictMode.ThreadPolicy.Builder () . Detectdiskreads () . Detectdiskwrites () . Detectnetwor
Android development: Tomcat server, client socket network connection problems and D-LINK port forwarding settings, androidtomcat
I used my computer to build a server. The first problem was that we needed port ing on the router to access our computer through the Internet. How to map ports can be found in this article:
Http://blog.csdn.net/zhoubin1992/article/details/45917775
1. D-LINK port forwarding setting
In Android development, we will encounter file transmission, which will involve data transmission. For example, if the size of a file is kb and the data type is int, and the data on the network is all byte data streams, an int-> byte [] method is required .. Let's look at a simple example.
Public class integer2byte {Public static void main (string [] ARGs) throws exception {Int I = 1989;Byte [] Buf = i2b2 (
Google released the open-source network framework volley at the Google I/O May Developer Conference in 2013. I heard that the response was very good, so I decided to spend some time studying it.
1. What does Volley do?
Volley is a library that makes networking for Android apps easier and most importantly, faster. (From: https://developers.google.com/events/io/sessions/325304728 ). This sentence is still abs
. Net network programming-use TcpClient and TcpListener to establish a connection between the client and the server, java Server Android Client
1. How to establish a connection in. NET
In the network, we can use the IP address to uniquely locate a host. In the host, we need to determine which packet is sent to, through the port number, simply put, the port nu
Source: http://www.imooc.com/code/1432The function of continue is to skip the remaining statements in the loop body to perform the next loop.For example, to print all the even numbers between 1--10, use the continue statement to implement the code:Operation Result:TaskImplementation function: Ask for all even numbers between 1 and 10.Implementation of the idea: Define a variable sum to save the cumulative value, define a variable I save 1 to 10 intege
last download of the place to downloadwhile (len = Is.read (b))! =-1) {raf.write (b, 0, Len); total + = Len; SYSTEM.OUT.PRINTLN ("thread" + threadId + "downloaded" + total);//Set current progress, is the sum of 3 threads currprogress + = len;pbar.setprogress (currprogress );//update the text by sending a message. The progress bar does not need to refresh the UI by sending a message, because the progress bar itself is a handler.sendemptymessage (1) used in another task;//Saves the current downlo
Source: http://www.imooc.com/code/1256The so-called constant, which we can understand as a special variable, whose value is set, is not allowed to change during program Operation .Syntax:final constant name = value;Using Constants in your program can improve the maintainability of your code. For example, in project development, we need to specify the user's gender, at this time can be defined as a constant sex, assigned to "male", in the need to specify a user-specific place to call this constan
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.