This post is slightly changed under http://www.cnblogs.com/hanyonglu/archive/2012/03/16/2399655.html.
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/ http://www.pudn.com/downloads397/sourcecode/book/detail1697495.html
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:
Push message:
Test results such as:
Simulator and real machine test pass.
If this error occurs when running: Java.lang.NoClassDefFoundError:org.androidpn.client.PersistentConnectionListener
Workaround:
Maybe your ADT version is too high.
First clean your project, run a try, if you still report the exception, the project will be deleted under the Lib folder, create a new Libs folder, the Asmack.jar file in, clean project run, problem solving!