This article describes the use of the ANDROIDPN project for push.
In the previous article, the solution to push in Android was mentioned, and one of the more mature solutions was to use the XMPP protocol to implement it. The ANDROIDPN project is an open source project that uses the XMPP protocol for information push. Here we introduce the use of the process.
Features of the Apndroid Push notification:
Fast integration: Provides a faster way to use than C2DM and avoids various restrictions.
No server Setup required: Reduce the additional server burden by using cloud services.
Can push messages to the site page at the same time, Android phone
Less power consumption, less traffic.
Specific configuration process:
First, we need to download Androidpn-client-0.5.0.zip and Androidpn-server-0.5.0-bin.zip.
: http://sourceforge.net/projects/androidpn/
Extract two packages, Eclipse Import client, configure target platform, open raw/androidpn.properties file, configure client program.
1. If the emulator is running the client program, configure the Xmpphost to 10.0.2.2[ The simulator considers 10.0.2.2 as the address of the host, 127.0.0.1 is the loopback address of the emulator itself, 10.0.2.1 represents the gateway address, 10.0.2.3 represents the DNS address, 10.0.2.15 represents the network address of the target device], and details about the emulator, You can refer to the relevant information, not detailed here.
Xmppport=5222 is the server's XMPP service listening port
Run Androidpn-server-0.5.0\bin\run.bat boot server, access http://127.0.0.1:7070/index.do from the browser (ANDROIDPN server has a lightweight Web server, On 7070-Port listening requests, accept user-entered text messages)
Running the client, the client initiates a connection request to the server, and after successful registration, the server can identify the client and maintain a long IP connection with the client.
2. If you are testing the simulator of other machines in the same LAN (or using the same wireless router's WiFi connection), you need to set this value to the server machine's LAN IP.
For example, your computer and Android phone are connected to the same wireless router WiFi, the computer's IP address is 192.168.1.2 and the IP address of the phone is 192.168.1.3, this time need to change this value to xmpphost=192.168.1.1 or power The IP address of the brain, it can be used on the phone.
3. If the test is not on the same LAN, we need to set this value to the IP address of the server.
The specific configuration is as follows:
My Computer IP is: 192.168.8.107
The server runs the main interface:
The push information is shown in the following interface:
The test results are as follows:
Finally the test passed in my simulator and the real machine. ^_^
Finally, hope that the reprint of friends can respect the author's labor results, plus reprint address: http://www.cnblogs.com/hanyonglu/archive/2012/03/16/2399655.html Thank you.
Complete. ^_^
Android push notification for information push use