import android.widget.Toast;
public class Security extends MainActivity {
Socket sock,sock1;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.security);
new Thread(new Runnable()
{
public void run()
{
try{
sock=new Socket(ip,port1);
BufferedReader br=new BufferedReader(new InputStreamReader(sock.getInputStream()));
String a=br.readLine();
Thread.sleep(2500);
Toast.makeText(getApplicationContext(),"Please Enter the result of operation for no "+a,Toast.LENGTH_LONG).show();
}
catch(UnknownHostException e)
{
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}).start();
}
}
安全啓動時無法查看烤麪包。我不知道爲什麼?它就像是在oncliklistener中應該是智慧的。無法看到裏面的烤麪包
只從上面的'MainThread'的Toast消息使用'ASyncTask'而不是原始'Thread'。這給你訪問'onPostExecute'這正是你在做什麼 – Blundell