I decided to study java and the creation of Android applications on it. So, Reg activ with all sorts of conditions:
public class Reg extends Activity{ TextView InfoText; Button Reg; Button Cancel; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.lregistration); InfoText = (TextView) findViewById(R.id.InfoText);//ΠΠ½ΡΠΎΡΠΌΠΈΡΡΡΡΠΈΠΉ ΡΠ΅ΠΊΡΡ Reg = (Button) findViewById(R.id.reg);//ΠΠ½ΠΎΠΏΠΊΠ° ΡΠ΅Π³ΠΈΡΡΡΠ°ΡΠΈΠΈ Cancel = (Button) findViewById(R.id.Cancel);//ΠΠ°Π·Π°Π΄ OnClickListener Click = new OnClickListener() { public void onClick(View v){ switch (v.getId()) { case R.id.reg: /*ΠΠΎΠ΄ ΠΏΡΠΈ Π½Π°ΠΆΠ°ΡΠΈΠΈ ΠΊΠ½ΠΎΠΏΠΊΠΈ Π Π΅Π³ΠΈΡΡΡΠ°ΡΠΈΡ*/ /*--------------------------------------------------------------*/ `
CONservice.getCon ();
InfoText.setText("olol"); /*--------------------------------------------------------------*/ break; case R.id.Cancel: /*ΠΠΎΠ΄ ΠΏΡΠΈ Π½Π°ΠΆΠ°ΡΠΈΠΈ ΠΊΠ½ΠΎΠΏΠΊΠΈ ΠΠ°Π·Π°Π΄*/ break; }}}; Reg.setOnClickListener(Click); }; };
File connecter: CONservice.java:
package service; import java.net.Socket; import java.net.UnknownHostException; import java.io.*; public class CONservice { static AffableThread mSecondThread; public static void main(String[] args) { getCon(); } public static void getCon(){ mSecondThread = new AffableThread(); mSecondThread.start(); } } class AffableThread extends Thread { @Override public void run() { try{ Socket socket = new Socket("127.0.0.1", 5555); }catch(UnknownHostException e){}catch(IOException e){} } }
That is, there is a certain screen with a button, and when you click on it, an attempt should be made to connect to the server and display the text "olol" on the screen. The server is running and waiting for connections, we launch the application through the emulsion, press the button - and voila - there is no connection, no errors, and only a vague olol inscription. It seems like not a psychic guessing that there is in the trunk. Help, good people))