Hi, i am a student and developpe an application with android.I don't
use the real phone,only the android emulator.I want to know how i can
use the GPRS with this emulator.I have tested to use the package
org.apache, but i did know how to use this package correctly.
Another thing, i have tried to use the java.io.* and java.net.*,
always not succes.Please help me.
i have add the permission,<uses-permission
android:name="android.permission.INTERNET"></uses-permission>
My code is below
/////////////////:**** On android
phone***/////////////////////////////:
192.168.1.6 is the ip address for the server web
3000 is a port that server listen to retrieve the data which are
sended by the emulator android
public class androidtracabilite extends Activity
{
/** Called when the activity is first created. */
private Socket socket;
public androidtracabilite()
{
try
{
socket=new Socket("192.168.1.6",3000);
}catch(Exception e)
{
}
}
@Override
public void onCreate(Bundle tracabilite)
{
super.onCreate(tracabilite);
setContentView(R.layout.main);
try{
envoiesocket();
}
catch(Exception e)
{
}
}
public void envoiesocket() throws Exception
{
System.out.println("Entrer dans la fonction");
TextView tv = (TextView)findViewById(R.id.myTextView);
StringBuilder sb = new StringBuilder("Envoie Socket");
BufferedReader plec = new BufferedReader(new InputStreamReader
(socket.getInputStream()));
PrintWriter pred = new PrintWriter(new BufferedWriter(new
OutputStreamWriter(socket.getOutputStream())),true);
pred.println("envoie de socket");
String read= plec.readLine();
plec.close();
pred.close();
socket.close();
sb.append(read);
tv.setText(sb);
}
Thank you for your help
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---