Mini2440Activity.java
[java]
package sg131971.mini2440;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import Android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
public class Mini2440Activity extends Activity {
private static int Connect_flag = 0;
private static int AutoRefresh_flag = 0;
private static int LED_flag[] = new int[4];
private Bitmap m_Bitmap;
private ImageView myImageView;
private Handler m_Handler = new Handler();
private String Board_IP;
private EditText myEditText;
private Button myButtonConnect;
private Button myButton0;
private Button myButton1;
private Button myButton2;
private Button myButton3;
private Button myButtonStatus;
private Button autoButton;
private Button manualButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myEditText = (EditText) findViewById(R.id.editText);
myButtonConnect = (Button) findViewById(R.id.myButtonConnect);
myButtonConnect.setOnClickListener(new ConnectListener());
myImageView = (ImageView) findViewById(R.id.imageView);
autoButton = (Button) findViewById(R.id.autoButton);
manualButton = (Button) findViewById(R.id.manualButton);
myButton0 = (Button) findViewById(R.id.myButton0);
myButton1 = (Button) findViewById(R.id.myButton1);
myButton2 = (Button) findViewById(R.id.myButton2);
myButton3 = (Button) findViewById(R.id.myButton3);
myButtonStatus = (Button) findViewById(R.id.myButtonStatus);
StopService();
}
public boolean onKeyDown(int keyCode, KeyEvent msg) {
if (keyCode == KeyEvent.KEYCODE_BACK)
{
finish();
System.exit(0);
}
return false;
}
private void StartService() {
// TODO Auto-generated method stub
m_Handler.postDelayed(m_RefreshImage, 0);
myButton0.setOnClickListener(new LED0Listener());
myButton1.setOnClickListener(new LED1Listener());
myButton2.setOnClickListener(new LED2Listener());
myButton3.setOnClickListener(new LED3Listener());
myButtonStatus.setOnClickListener(new StatusListener());
autoButton.setOnClickListener(new AutoRefresh());
manualButton.setOnClickListener(new ManualRefresh());
}
private void StopService() {
// TODO Auto-generated method stub
m_Handler.removeCallbacks(m_RefreshImage);
myImageView.setImageResource(R.drawable.first);
myButton0.setOnClickListener(new DefaultListener());
myButton1.setOnClickListener(new DefaultListener());
myButton2.setOnClickListener(new DefaultListener());
myButton3.setOnClickListener(new DefaultListener());
myButtonStatus.setOnClickListener(new DefaultListener());
autoButton.setOnClickListener(new DefaultListener());
manualButton.setOnClickListener(new DefaultListener());
}
public class ConnectListener implements OnClickListener {
public void onClick(View v) {
// TODO Auto-generated method stub
Board_IP = myEditText.getText().toString();
if (Connect_flag == 0) {
Connect_flag = 1;
StartService();
myButtonConnect.setText('Disconnect');
showMessage('已连接:' + Board_IP);
} else {
Connect_flag = 0;
AutoRefresh_flag = 0;
StopService();
myButtonConnect.setText('Connect');
上一篇:Android + Mini2440 无线网络视频监控系统 mjpg-streamer的移植
下一篇:mini2440上Apache php的socket通信
推荐阅读最新更新时间:2024-11-03 18:01
设计资源 培训 开发板 精华推荐
- L7809C 具有短路保护的高输出电流的典型应用
- 【已验证】三合一NFC门卡
- AMS1117-1.2V3.3V5V降压稳压模块
- LTC4069 的典型应用 - 采用 NTC 热敏电阻输入的 2 x 2 DFN 独立 750mA 锂离子电池充电器
- LT1021BMH-10 具有升压输出电流且无电流限制的电压基准的典型应用
- 使用 Semtech 的 EZ1082 的参考设计
- LT3091MPR 并联线性稳压器的典型应用
- 使用 LTC2367IDE-16、16 位、500ksps SAR ADC 的典型应用
- TWR-K60F120M: Kinetis K60 120 MHz塔式系统模块
- 涂鸦Zigbee/BLE多模无线网关