package net.npaka.socketex; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import net.npaka.socketex.TestAccelerometer.TickHandler; //ソケット通信 public class SocketEx extends Activity private final static int WC=LinearLayout.LayoutParams.WRAP_CONTENT; private final static int MP=LinearLayout.LayoutParams.MATCH_PARENT; //IPアドレスの指定(1) private TextView lblReceive;//受信ラベル private EditText edtSend; //送信エディットテキスト private boolean error; //エラー private final Handler handler=new Handler();//ハンドラ //アクティビティ起動時に呼ばれる @Override public void onCreate(Bundle bundle) { super.onCreate(bundle); //レイアウトの生成 LinearLayout layout=new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); setContentView(layout); /*//送信エディットテキストの生成 edtSend=new EditText(this); edtSend.setId(2); edtSend.setText("",TextView.BufferType.NORMAL); edtSend.setLayoutParams(new LinearLayout.LayoutParams(MP,WC)); layout.addView(edtSend); */ //送信ボタンの生成 btnSend.setText("送信"); btnSend.setOnClickListener(this); btnSend.setLayoutParams(new LinearLayout.LayoutParams(WC,WC)); layout.addView(btnSend); //受信ラベルの生成 lblReceive=new TextView(this); lblReceive.setId(1); lblReceive.setText(""); lblReceive.setTextSize(16.0f); lblReceive.setLayoutParams(new LinearLayout.LayoutParams(MP,WC)); layout.addView(lblReceive); } //アクティビティ開始時に呼ばれる @Override public void onStart() { super.onStart(); //スレッドの生成 public void run() { try { connect(IP,8080); } } }; thread.start(); } //アクティビティの停止時に呼ばれる @Override public void onStop() { super.onStop(); disconnect(); } //受信テキストの追加 //ハンドラの生成 public void run() { lblReceive.setText(text+BR+ lblReceive.getText()); } }); } //接続 int size; String str; byte[] w=new byte[1024]; try { //ソケット接続(2) addText("接続中"); in =socket.getInputStream(); out=socket.getOutputStream(); addText("接続完了"); //受信ループ(3) while (socket!=null && socket.isConnected()) { //データの受信(4) size=in.read(w); if (size<=0) continue; //ラベルへの文字列追加 addText(str); } addText("通信失敗しました"); } } //切断 private void disconnect() { try { socket.close(); socket=null; } } //ボタンクリックイベントの処理 //スレッッドの生成 error=false; try { //データの送信(5) if (socket!=null && socket.isConnected()) { TestAccelerometer.TickHandler a = new TestAccelerometer().new TickHandler(); edtStr = a.getStr(); byte[] w=edtStr.getBytes("UTF8"); out.write(w); out.flush(); } error=true; } //ハンドラの生成 if (!error) { edtSend.setText("",TextView.BufferType.NORMAL); } else { addText("通信失敗しました"); } }}); }}); thread.start(); } }
Standard input is empty
Main.java:19: class SocketEx is public, should be declared in a file named SocketEx.java public class SocketEx extends Activity ^ Main.java:2: package android.app does not exist import android.app.Activity; ^ Main.java:3: package android.graphics does not exist import android.graphics.Color; ^ Main.java:4: package android.os does not exist import android.os.Bundle; ^ Main.java:5: package android.os does not exist import android.os.Handler; ^ Main.java:6: package android.view does not exist import android.view.View; ^ Main.java:7: package android.view does not exist import android.view.Window; ^ Main.java:8: package android.widget does not exist import android.widget.Button; ^ Main.java:9: package android.widget does not exist import android.widget.EditText; ^ Main.java:10: package android.widget does not exist import android.widget.LinearLayout; ^ Main.java:11: package android.widget does not exist import android.widget.TextView; ^ Main.java:16: package net.npaka.socketex.TestAccelerometer does not exist import net.npaka.socketex.TestAccelerometer.TickHandler; ^ Main.java:19: cannot find symbol symbol: class Activity public class SocketEx extends Activity ^ Main.java:20: package View does not exist implements View.OnClickListener { ^ Main.java:28: cannot find symbol symbol : class TextView location: class net.npaka.socketex.SocketEx private TextView lblReceive;//????? ^ Main.java:29: cannot find symbol symbol : class EditText location: class net.npaka.socketex.SocketEx private EditText edtSend; //??????????? ^ Main.java:30: cannot find symbol symbol : class Button location: class net.npaka.socketex.SocketEx private Button btnSend; //????? ^ Main.java:37: cannot find symbol symbol : class Handler location: class net.npaka.socketex.SocketEx private final Handler handler=new Handler();//???? ^ Main.java:41: cannot find symbol symbol : class Bundle location: class net.npaka.socketex.SocketEx public void onCreate(Bundle bundle) { ^ Main.java:149: cannot find symbol symbol : class View location: class net.npaka.socketex.SocketEx public void onClick(View v) { ^ Main.java:22: package LinearLayout does not exist private final static int WC=LinearLayout.LayoutParams.WRAP_CONTENT; ^ Main.java:23: package LinearLayout does not exist private final static int MP=LinearLayout.LayoutParams.MATCH_PARENT; ^ Main.java:37: cannot find symbol symbol : class Handler location: class net.npaka.socketex.SocketEx private final Handler handler=new Handler();//???? ^ Main.java:42: cannot find symbol symbol : variable super location: class net.npaka.socketex.SocketEx super.onCreate(bundle); ^ Main.java:43: cannot find symbol symbol : variable Window location: class net.npaka.socketex.SocketEx requestWindowFeature(Window.FEATURE_NO_TITLE); ^ Main.java:46: cannot find symbol symbol : class LinearLayout location: class net.npaka.socketex.SocketEx LinearLayout layout=new LinearLayout(this); ^ Main.java:46: cannot find symbol symbol : class LinearLayout location: class net.npaka.socketex.SocketEx LinearLayout layout=new LinearLayout(this); ^ Main.java:47: cannot find symbol symbol : variable Color location: class net.npaka.socketex.SocketEx layout.setBackgroundColor(Color.rgb(255,255,255)); ^ Main.java:48: cannot find symbol symbol : variable LinearLayout location: class net.npaka.socketex.SocketEx layout.setOrientation(LinearLayout.VERTICAL); ^ Main.java:59: cannot find symbol symbol : class Button location: class net.npaka.socketex.SocketEx btnSend=new Button(this); ^ Main.java:62: package LinearLayout does not exist btnSend.setLayoutParams(new LinearLayout.LayoutParams(WC,WC)); ^ Main.java:66: cannot find symbol symbol : class TextView location: class net.npaka.socketex.SocketEx lblReceive=new TextView(this); ^ Main.java:70: cannot find symbol symbol : variable Color location: class net.npaka.socketex.SocketEx lblReceive.setTextColor(Color.rgb(0,0,0)); ^ Main.java:71: package LinearLayout does not exist lblReceive.setLayoutParams(new LinearLayout.LayoutParams(MP,WC)); ^ Main.java:40: method does not override or implement a method from a supertype @Override ^ Main.java:78: cannot find symbol symbol : variable super location: class net.npaka.socketex.SocketEx super.onStart(); ^ Main.java:76: method does not override or implement a method from a supertype @Override ^ Main.java:95: cannot find symbol symbol : variable super location: class net.npaka.socketex.SocketEx super.onStop(); ^ Main.java:93: method does not override or implement a method from a supertype @Override ^ Main.java:161: package TestAccelerometer does not exist TestAccelerometer.TickHandler a = new TestAccelerometer().new TickHandler(); ^ Main.java:161: cannot find symbol symbol: class TestAccelerometer TestAccelerometer.TickHandler a = new TestAccelerometer().new TickHandler(); ^ Main.java:174: package TextView does not exist edtSend.setText("",TextView.BufferType.NORMAL); ^ 42 errors
Standard output is empty