基本信息
源码名称:Android手机通过wifi控制电脑程序源码
源码大小:0.29M
文件格式:.rar
开发语言:Java
更新时间:2015-09-10
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
package pl.gregorl.Grzmote;
import java.io.IOException;
import java.net.UnknownHostException;
import pl.gregorl.Grzmote.Common.Command;
import pl.gregorl.Grzmote.Common.ICommand;
import pl.gregorl.Grzmote.Network.CommandSender;
import pl.gregorl.Grzmote.Network.ICommandSender;
import android.app.AlertDialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class CommandSendingActivity extends BaseActivity implements ICommandSendingActivity {
protected ICommandSender commandSender;
public CommandSendingActivity()
{
super();
commandSender = new CommandSender();
}
public void sendCommand(ICommand command) throws UnknownHostException, IOException
{
this.commandSender.Send(Settings.getServerAddress(),command);
}
protected void adjustImageButton(ImageButton button,final String command) {
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
try {
sendCommand(new Command(command));
} catch (UnknownHostException e) {
showAlertOnError(e);
} catch (IOException e) {
showAlertOnError(e);
} catch(Exception exc){
showAlertOnError(exc);
}
}
});
}
private void showAlertOnError(Exception e){
AlertDialog a = (new AlertDialog.Builder(getBaseContext())).create();
a.setMessage("Connection problem: " e.getLocalizedMessage());
a.show();
}
}