public class HandleServer extends Service { private Server ser=null; public String IpAddress=null; public int port=0; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); } @Override public void onDestroy() { // TODO Auto-generated method stub try { Toast.makeText(this, "Closing", Toast.LENGTH_LONG).show(); //ser.Close(); Toast.makeText(this, "Closed", Toast.LENGTH_LONG).show(); super.onDestroy(); } catch (Exception e) { // TODO Auto-generated catch block Toast.makeText(this, "Close error :" + e.getMessage(), Toast.LENGTH_LONG).show(); } } @Override public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub Toast.makeText(this, "starting", Toast.LENGTH_SHORT).show(); try{ ser = new Server(); IpAddress= ser.IpAddress(); port =ser.Port(); ser.Start(); //IPAddress.Clients(this, findViewById(R.id.hello_world)); } catch(Exception ex){ //((TextView)findViewById(R.id.txtStatus)).setText(ex.getMessage()); Toast.makeText(this, ex.getMessage(), Toast.LENGTH_SHORT).show(); } } @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub return super.onStartCommand(intent, flags, startId); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)