Android-Socket transmission GPRS network, android-socketgprs
The mobile phone uses GPRS network and server Socket communication, code: http://download.csdn.net/detail/wu20093346/7768481
Use UDP protocol and Socket debugging tools for testing.
SocketActivity. java:
package com.example.socket;import java.net.DatagramPacket;import java.net.DatagramSocket;import java.net.InetAddress;import android.os.Bundle;import android.app.Activity;import android.view.View;import android.widget.Button;import android.view.View.OnClickListener;public class SocketActivity extends Activity {private Button startButton = null;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_socket);startButton = (Button)findViewById(R.id.startListener);startButton.setOnClickListener(new StartSocketListener());}class StartSocketListener implements OnClickListener{@Overridepublic void onClick(View v){new ServerThread().start();}}class ServerThread extends Thread{public void run(){try{DatagramSocket socket = new DatagramSocket(1234);InetAddress serverAddress = InetAddress.getByName("115.238.249.92");String str = "hello";byte data[] = str.getBytes();DatagramPacket packet = new DatagramPacket(data,data.length,serverAddress,1234);socket.send(packet);}catch (Exception e){e.printStackTrace();}}}}
Activity_socket.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".SocketActivity" > <Button android:id="@+id/startListener" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:onClick="OnClickListener" android:text="@string/Start" /></RelativeLayout>
The Socket debugging tool creates a UDP Server listening port 1234 with the local IP address 115.238.249.92. Install and run apk, and press Send to receive data from the server.
Note: add the following in AndroidManifest. xml:
<uses-permission android:name="android.permission.INTERNET" />
Can android phones connected to China Mobile's GPRS network communicate with each other?
A little speechless. . . . . .
CMWAP is a mobile custom network and can only be connected to WAP network, unless you use the HTTP Network
The gprs http Proxy protocol or gateway protocol literally refers to the universal grouping wireless service. In fact, things are transformed to use the existing GSM network and mobile Internet. The so-called G technology refers to the GPRS
CMWAP is connected to GPRS. Based on the customized GSM network, China Mobile's network is connected to the Internet. . . . . . How can I answer you, as you said, "Are you driving on the road ?"
The operating system Android is based on a mobile phone platform. You are talking about two mobile phones based on GSM. Of course, GPRS is supported. The courses include CMWAP and CMNET.
What is the transmission speed of the GPRS network?
GPRS provides a transmission rate of 115kbps (the maximum value is 171.2 kbps, excluding FEC ).
However, EDGE is almost covered, and the transmission rate can reach 384 kbps at the peak.