我希望每2分钟后加载一次数据 . 我该怎么做?我已经实现了这个 . 但它不起作用 .
new Handler().postDelayed(new Runnable() {
public void run() {
getData();
Toast.makeText(getContext(),"Loading new data",Toast.LENGTH_SHORT).show();
}
}, 10);
public void getData(){
SharedPreferences preferences = getContext().getSharedPreferences(SP, MODE_PRIVATE);
final String ip_addr = preferences.getString("ip_addr",null);
final String port = preferences.getString("port_no",null);
final ProgressDialog progressDialog = new ProgressDialog(getContext());
progressDialog.setMessage("Please Wait...");
progressDialog.show();
String url = "http://"+ip_addr+":"+port+"/new_crushing_api.php";
//code
1 回答