Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 插座及;SDK最小版本_Android - Fatal编程技术网

Android 插座及;SDK最小版本

Android 插座及;SDK最小版本,android,Android,我之前编写了一个应用程序,它使用socket类创建TCP/IP客户端,如下所示: Socket soc; DataOutputStream out; DataInputStream in; //in try-catch loop soc = new ("192.168.1.101", 100); out = new DataOutputStream(socket.getOutputStream()); in = new DataInputStream(socket.getInputStream

我之前编写了一个应用程序,它使用socket类创建TCP/IP客户端,如下所示:

Socket soc;
DataOutputStream out;
DataInputStream in;

//in try-catch loop
soc = new ("192.168.1.101", 100);
out = new DataOutputStream(socket.getOutputStream());
in = new DataInputStream(socket.getInputStream());

.....//code on I/O through socket
在我以前的ap上运行sdk 9时,它运行得很好

现在,我正在尝试在我的新应用程序中使用相同的函数,它使用fragment和所需的sdk11。但只要运行套接字代码,应用程序就会崩溃。 一旦我在manifest.xml中将android:minSdkVersion更改为9,它就会再次工作。但我需要minSDK 11来制作碎片

我该怎么办?我只有几个月的Android代码,如果我问了一个愚蠢的问题,请原谅。非常感谢

编辑:这是触发套接字函数的OnClick函数:

private Button.OnClickListener m_BtnConnectDisconnectOnClick = new Button.OnClickListener()
{
   public void onClick(View v)
   {
         try
         {
          //Obtaining IP Address & Port number
          String str_ip = m_EditPumpIP.getText().toString();
          int int_port = Integer.parseInt(m_EditPumpPort.getText().toString());

          //Establish Pump Connection
          socket = new Socket(str_ip, int_port);
          out = new DataOutputStream(socket.getOutputStream());
          in = new DataInputStream(socket.getInputStream());

          //Update Status
          m_TextSystemStatus.setText("OK");
         }
         catch (IOException e)
         {
           //Update Status
           m_TextSystemStatus.setText("Fail");
         }
   }
};
把这个放在异步任务中

//Establish Pump Connection
          socket = new Socket(str_ip, int_port);
          out = new DataOutputStream(socket.getOutputStream());
          in = new DataInputStream(socket.getInputStream());

将其放入异步任务中

//Establish Pump Connection
          socket = new Socket(str_ip, int_port);
          out = new DataOutputStream(socket.getOutputStream());
          in = new DataInputStream(socket.getInputStream());

尝试在清单中设置
发布日志,告诉我您正在ui上运行网络thread@MoshErsan他需要明斯克11@DjHacktorReborn是的,你是对的。@user2155836只要试着在新线程中运行你的代码。试着在你的清单中设置你的日志,可以告诉我你在ui上运行网络thread@MoshErsan他需要明斯克11@DjHacktorReborn是的,您是对的。@user2155836请尝试在新线程中运行您的代码。