Example usage for android.os Handler sendEmptyMessage

List of usage examples for android.os Handler sendEmptyMessage

Introduction

In this page you can find the example usage for android.os Handler sendEmptyMessage.

Prototype

public final boolean sendEmptyMessage(int what) 

Source Link

Document

Sends a Message containing only the what value.

Usage

From source file:org.openremote.android.console.AppSettingsActivity.java

/**
 * Check if Client Authentication is enabled on the server if so 
 * enable to SSL button in the GUI/*w w w.jav  a2s  .c om*/
 */
private void checkAuthentication() {
    final Handler checkHandler = new Handler() {
        public void handleMessage(Message msg) {
            final ToggleButton sslToggleButton = (ToggleButton) findViewById(R.id.ssl_toggle);
            if (msg.what == 1) {
                AppSettingsModel.enableSSL(AppSettingsActivity.this, true);
                sslToggleButton.setChecked(true);
                // show pin
                findViewById(R.id.ssl_pin_row).setVisibility(View.VISIBLE);
            } else {
                AppSettingsModel.enableSSL(AppSettingsActivity.this, false);
                sslToggleButton.setChecked(false);
                // hide pin
                findViewById(R.id.ssl_pin_row).setVisibility(View.GONE);
            }
        }
    };
    new Thread() {
        public void run() {
            if (this.checkAuthentication()) {
                checkHandler.sendEmptyMessage(1);
            } else {
                checkHandler.sendEmptyMessage(0);
            }
        }

        private boolean checkAuthentication() {
            boolean returnValue = false;

            if (!TextUtils.isEmpty(currentServer)) {
                try {
                    HttpRequestBase request = null;
                    HttpResponse response = null;
                    HttpParams params = new BasicHttpParams();

                    // set time-out at 3 seconds
                    HttpConnectionParams.setConnectionTimeout(params, 3 * 1000);
                    HttpConnectionParams.setSoTimeout(params, 3 * 1000);

                    HttpClient client = new DefaultHttpClient(params);
                    request = new HttpGet(new URL(currentServer + "/rest/authentication/check").toURI());

                    response = client.execute(request);

                    returnValue = (response.getStatusLine().getStatusCode() == 200) ? true : false;
                } catch (IOException e) {
                    returnValue = false;
                    Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
                } catch (IllegalArgumentException e) {
                    returnValue = false;
                    Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Can't check authentication: ", e);
                } catch (URISyntaxException e) {
                    returnValue = false;
                    Log.e(Constants.LOG_CATEGORY + "AUTH_CHECK", "Invalid URI: ", e);
                }
            }
            return returnValue;
        }
    }.start();
}

From source file:com.tcl.lzhang1.mymusic.ui.MusicListAcitivity.java

/**
 * load data//from   w w w .  ja v a  2 s.c o m
 * 
 * @param pageIndex
 * @param pageSize
 * @param tag
 * @param orderCol
 * @param handler
 */
public void loadData(final int pageIndex, final int pageSize, final int tag, final String orderCol,
        final Handler handler) {
    new Thread(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            Message message = handler.obtainMessage();
            try {
                if (tag == UIHelper.LISTVIEW_ACTION_REFRESH) {// scan music

                }

                @SuppressWarnings("unchecked")
                List<SongModel> msongs = (List<SongModel>) mDbOperator.sliptPage(pageIndex, pageSize, orderCol);
                message.what = LOADDATA_SUCCESS;
                message.obj = msongs;
                message.arg1 = msongs.size();
                message.arg2 = tag;
                handler.sendMessage(message);
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
                handler.sendEmptyMessage(LOADDATA_FAILED);
            }

        }
    }).start();
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void getOPSIDepotConfig(final String depot) {
    final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait),
            String.format(getString(R.string.pd_getdepotconfigfor), depot), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();/*from w  w  w  .  j  a  v a  2s  .co  m*/
            if (GlobalVar.getInstance().getError().equals("null")) {
                Intent i = new Intent(Main.this, ShowOpsiHostParamsListView.class);
                Bundle b = new Bundle();
                b.putString("hostparams", opsiresult.toString());
                b.putString("pc", choosendepot);
                b.putString("opsitype", "OpsiConfigserver");
                i.putExtras(b);
                startActivityForResult(i, SHOW_OPSI_DEPOT_REQUEST);
            } else {
                new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                        GlobalVar.getInstance().getError(), false);
            }

        }
    };
    Thread checkUpdate = new Thread() {
        public void run() {
            Looper.prepare();
            JSONArray JSONparams = new JSONArray();
            JSONparams.put(depot);
            opsiresult = new JSONObject();
            opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip,
                    serverport, "getDepot_hash", JSONparams, serverusername, serverpasswd);
            handler.sendEmptyMessage(0);
        }
    };
    checkUpdate.start();
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void buttonListener(final View view) {
    if (vibrate) {
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }//from   w w w  . j av  a 2s  . co  m
    // new Functions().noPreferences(Main.this,
    // getString(R.string.gen_title_error),
    // getString(R.string.gen_setpreferences));
    if (!new Functions().checkPreferences(Main.this)) {
        new Functions().noPreferences(Main.this, getString(R.string.gen_title_error),
                getString(R.string.gen_setserverpreferences));
        return;
    }
    // noPreferences(Main.this,
    // getString(R.string.gen_title_error),
    // getString(R.string.gen_setpreferences));
    switch (view.getId()) {
    case R.id.bt_scanqr:
        // Intent intent = new
        // Intent("com.google.zxing.client.android.SCAN");
        // intent.setPackage("com.google.zxing.client.android");
        // intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        // setResult(RESULT_OK, intent);
        // startActivityForResult(intent, 0);
        Intent qrDroid = new Intent("la.droid.qr.scan");
        qrDroid.putExtra("la.droid.qr.complete", true);
        try {
            startActivityForResult(qrDroid, GET_QR);
        } catch (ActivityNotFoundException activity) {
            Functions.qrDroidRequired(Main.this);
        }

        break;

    case R.id.bt_getopsiclients:
        Log.d("Barcode", "getopsiclient");
        // if (Networking.isConnected(Main.this)) {
        getOpsiClientsTask();
        // } else {
        // Toast.makeText(Main.this, R.string.to_wifinotconnected,
        // Toast.LENGTH_LONG).show();
        // }
        break;
    case R.id.bt_defineclientselection:
        if (Networking.isConnected(Main.this)) {
            final ProgressDialog dialog = ProgressDialog.show(Main.this,
                    getString(R.string.gen_title_pleasewait), getString(R.string.pd_getclients), true);
            final Handler handler = new Handler() {
                public void handleMessage(Message msg) {
                    dialog.dismiss();
                    if (GlobalVar.getInstance().getError().equals("null")) {
                        if (doit.equals("serverdown")) {
                            Toast.makeText(Main.this,
                                    String.format(getString(R.string.to_servernotrechable), serverip),
                                    Toast.LENGTH_LONG).show();
                        }
                    } else {
                        new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                                GlobalVar.getInstance().getError(), false);
                    }
                }
            };

            Thread checkUpdate = new Thread() {
                public void run() {
                    Looper.prepare();

                    if (Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) {
                        doit = "true";
                        Intent i = new Intent(Main.this, ShowOpsiClientFilter.class);
                        startActivity(i);
                    } else {
                        doit = "serverdown";
                    }
                    handler.sendEmptyMessage(0);

                }
            };
            checkUpdate.start();
        } else {
            Toast.makeText(Main.this, R.string.to_wifinotconnected, Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.bt_createopsiclient:
        // new Functions().notImplementet(Main.this);
        Intent i = new Intent(Main.this, ShowOpsiCreateClient.class);
        startActivity(i);
        break;
    case R.id.bt_showdepotconfig:
        // new Functions().notImplementet(Main.this);
        Log.d("Barcode", "depotconfig");
        if (Networking.isConnected(Main.this)) {
            getOPSIDepots();
        } else {
            Toast.makeText(Main.this, R.string.to_wifinotconnected, Toast.LENGTH_LONG).show();
        }
        break;
    // case R.id.bt_test:
    // ArrayList<String> test = new ArrayList<String>();
    // test.add("test1");
    // test.add("test2");
    // test.add("test3");
    // test.add("test4");
    // ShowOpsiClientOptionsButtonDialog buttondialog = new
    // ShowOpsiClientOptionsButtonDialog(Main.this,test);
    // buttondialog.setTitle("testtitle");
    // buttondialog.show();
    // break;
    }

}

From source file:com.dedipower.portal.android.TicketLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ticketlanding);
    final ListView list = (ListView) findViewById(R.id.TicketList);

    final ProgressDialog dialog = ProgressDialog.show(this, "DediPortal", "Please wait: loading data....",
            true);//  w w  w .  j av  a  2s  .  c  o m
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                OpenTicketsAdaptor adapter = new OpenTicketsAdaptor(TicketLanding.this, listOfTickets,
                        API.SessionID);
                list.setAdapter(adapter);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                TicketAPI = API.PortalQuery("tickets", "none");
                Success = TicketAPI.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occured.";
                Success = "false";
            }

            if (Success.equals("false")) {
                try {
                    ErrorMessage = TicketAPI.getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "A JSON parsing error prevented an exact error message to be determined.";
                }
            } else {
                Log.i("APIFuncs", TicketAPI.toString());
                try {
                    Tickets = TicketAPI.getJSONArray("tickets");
                    ErrorMessage = "";
                } catch (JSONException e) {
                    ErrorMessage = "There are no open tickets for your account.";
                }

                //OK lets actually do something useful
                //ListView list = (ListView)findViewById(R.id.TicketList);
                //List<OpenTickets> listOfTickets = new ArrayList<OpenTickets>();
                int TicketCount = Tickets.length();

                if (TicketCount == 0) {
                    ErrorMessage = "There are no open tickets for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < TicketCount; i++) {
                    JSONObject CurrentTicket = null;
                    try {
                        CurrentTicket = Tickets.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }
                    try {
                        listOfTickets.add(new OpenTickets(CurrentTicket.getString("status"),
                                CurrentTicket.getInt("id"), CurrentTicket.getString("server"),
                                CurrentTicket.getString("email"), CurrentTicket.getString("subject"),
                                CurrentTicket.getInt("createdat"), CurrentTicket.getInt("lastupdate"), false));
                        //CurrentTicket.getBoolean("subscriber")));
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }

            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}

From source file:net.networksaremadeofstring.pulsant.portal.TicketLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ticketlanding);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Tickets");

    final ListView list = (ListView) findViewById(R.id.TicketList);

    final ProgressDialog dialog = ProgressDialog.show(this, "Pulsant Portal",
            "Please wait: loading tickets....", true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();//from w w  w  .jav a2 s.  c  o m
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                OpenTicketsAdaptor adapter = new OpenTicketsAdaptor(TicketLanding.this, listOfTickets,
                        API.SessionID);
                list.setAdapter(adapter);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                TicketAPI = API.PortalQuery("tickets", "none");
                Success = TicketAPI.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occured.";
                Success = "false";
            }

            if (Success.equals("false")) {
                try {
                    ErrorMessage = TicketAPI.getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "A JSON parsing error prevented an exact error message to be determined.";
                }
            } else {
                Log.i("APIFuncs", TicketAPI.toString());
                try {
                    Tickets = TicketAPI.getJSONArray("tickets");
                    ErrorMessage = "";
                } catch (JSONException e) {
                    ErrorMessage = "There are no open tickets for your account.";
                }

                //OK lets actually do something useful
                //ListView list = (ListView)findViewById(R.id.TicketList);
                //List<OpenTickets> listOfTickets = new ArrayList<OpenTickets>();
                int TicketCount = Tickets.length();

                if (TicketCount == 0) {
                    ErrorMessage = "There are no open tickets for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < TicketCount; i++) {
                    JSONObject CurrentTicket = null;
                    try {
                        CurrentTicket = Tickets.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }
                    try {
                        listOfTickets.add(new OpenTickets(CurrentTicket.getString("status"),
                                CurrentTicket.getInt("id"), CurrentTicket.getString("server"),
                                CurrentTicket.getString("email"), CurrentTicket.getString("subject"),
                                CurrentTicket.getInt("createdat"), CurrentTicket.getInt("lastupdate"), false));
                        //CurrentTicket.getBoolean("subscriber")));
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }

            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}

From source file:eu.dirtyharry.androidopsiadmin.Main.java

public void event_opsisenddepotconfigchanges() {
    final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait),
            String.format(getString(R.string.pd_senddepotchangesfor), choosendepot), true);
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();//from   w ww  .  j  av a  2  s .  co  m
            if (!GlobalVar.getInstance().getError().equals("null")) {
                new Functions().msgBox(Main.this, getString(R.string.gen_title_error),
                        GlobalVar.getInstance().getError(), false);
            }
        }
    };
    Thread checkUpdate = new Thread() {
        public void run() {
            Looper.prepare();
            JSONArray test = new JSONArray();
            JSONObject params = new JSONObject();
            try {
                params.put("id", choosendepot);
                params.put("type", "OpsiConfigserver");
                for (int i = 0; i < resultconfignames.size(); i++) {
                    params.put(resultconfignames.get(i), resultconfigvalues.get(i));
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
            }

            test.put(params);
            opsiresult = new JSONObject();
            opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip,
                    serverport, "host_updateObject", test, serverusername, serverpasswd);
            try {
                if (!opsiresult.isNull("error")) {
                    GlobalVar.getInstance().setError(opsiresult.getString("error"));
                }

            } catch (JSONException e) {
                e.printStackTrace();
            }
            handler.sendEmptyMessage(0);
        }
    };
    checkUpdate.start();
}

From source file:io.realm.Realm.java

/**
 * All changes since {@link io.realm.Realm#beginTransaction()} are persisted to disk and the
 * Realm reverts back to being read-only. An event is sent to notify all other realm instances
 * that a change has occurred. When the event is received, the other Realms will get their
 * objects and {@link io.realm.RealmResults} updated to reflect
 * the changes from this commit.// w  w  w .jav  a2s .c  o  m
 *
 * @throws java.lang.IllegalStateException If the write transaction is in an invalid state or incorrect thread.
 */
public void commitTransaction() {
    checkIfValid();
    transaction.commitAndContinueAsRead();

    for (Map.Entry<Handler, String> handlerIntegerEntry : handlers.entrySet()) {
        Handler handler = handlerIntegerEntry.getKey();
        String realmPath = handlerIntegerEntry.getValue();

        // Notify at once on thread doing the commit
        if (handler.equals(this.handler)) {
            sendNotifications();
            continue;
        }

        // For all other threads, use the Handler
        if (realmPath.equals(configuration.getPath()) // It's the right realm
                && !handler.hasMessages(REALM_CHANGED) // The right message
                && handler.getLooper().getThread().isAlive() // The receiving thread is alive
        ) {
            handler.sendEmptyMessage(REALM_CHANGED);
        }
    }
}

From source file:com.dedipower.portal.android.InvoiceLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.invoicelanding);
    final ListView list = (ListView) findViewById(R.id.InvoiceList);

    final ProgressDialog dialog = ProgressDialog.show(this, "DediPortal", "Please wait: loading data....",
            true);//from  w  ww .ja  v  a2s  . c  o  m
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                InvoiceAdaptor adapter = new InvoiceAdaptor(InvoiceLanding.this, listOfInvoices, API.SessionID);
                list.setAdapter(adapter);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                InvoiceAPIReturn = API.PortalQueryHack("invoices", "", "");
                Success = InvoiceAPIReturn.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occured.";
                Success = "false";
            }

            if (Success.equals("false")) {
                Log.i("API", "Success was false");
                try {
                    ErrorMessage = InvoiceAPIReturn.getJSONObject("hackReturn").getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "A JSON parsing error prevented an exact error message to be determined.";
                }
            } else {
                int InvoiceCount = 0;
                Log.i("APIFuncs", InvoiceAPIReturn.toString());
                try {
                    Invoices = InvoiceAPIReturn.getJSONObject("hackReturn").getJSONArray("data");
                    InvoiceCount = Invoices.length();
                    ErrorMessage = "";
                } catch (JSONException e) {
                    ErrorMessage = "There don't appear to be any invoices for your account.....";
                    InvoiceCount = 0;
                    Log.e("API", "There was an eror parsing the array");
                    Log.e("API", e.getMessage());
                }

                //OK lets actually do something useful

                if (InvoiceCount == 0) {
                    Success = "false";
                    ErrorMessage = "There are no invoices for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < InvoiceCount; i++) {
                    JSONObject CurrentInvoice = null;
                    try {
                        CurrentInvoice = Invoices.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }
                    try {
                        if (CurrentInvoice.getString("type").equals("invoice"))
                            listOfInvoices.add(new Invoices(CurrentInvoice.getString("ref"),
                                    CurrentInvoice.getDouble("amount"), CurrentInvoice.getString("details"),
                                    CurrentInvoice.getLong("date")));
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }

            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}

From source file:net.networksaremadeofstring.pulsant.portal.InvoiceLanding.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.invoicelanding);
    final ListView list = (ListView) findViewById(R.id.InvoiceList);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Accounting");

    final ProgressDialog dialog = ProgressDialog.show(this, "Pulsant Portal", "Please wait: loading data....",
            true);/*from www .java 2 s  .c  o  m*/
    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();
            if (Success.equals("true")) {
                UpdateErrorMessage(ErrorMessage);
                InvoiceAdaptor adapter = new InvoiceAdaptor(InvoiceLanding.this, listOfInvoices, API.SessionID);
                list.setAdapter(adapter);
            } else {
                UpdateErrorMessage(ErrorMessage);
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            try {
                InvoiceAPIReturn = API.PortalQueryHack("invoices", "", "");
                Success = InvoiceAPIReturn.getString("success");
            } catch (JSONException e) {
                ErrorMessage = "An unrecoverable JSON Exception occured.";
                Success = "false";
            }

            if (Success.equals("false")) {
                Log.i("API", "Success was false");
                try {
                    ErrorMessage = InvoiceAPIReturn.getJSONObject("hackReturn").getString("msg");
                } catch (JSONException e) {
                    ErrorMessage = "A JSON parsing error prevented an exact error message to be determined.";
                }
            } else {
                int InvoiceCount = 0;
                Log.i("APIFuncs", InvoiceAPIReturn.toString());
                try {
                    Invoices = InvoiceAPIReturn.getJSONObject("hackReturn").getJSONArray("data");
                    InvoiceCount = Invoices.length();
                    ErrorMessage = "";
                } catch (JSONException e) {
                    ErrorMessage = "There don't appear to be any invoices for your account.....";
                    InvoiceCount = 0;
                    Log.e("API", "There was an eror parsing the array");
                    Log.e("API", e.getMessage());
                }

                //OK lets actually do something useful

                if (InvoiceCount == 0) {
                    Success = "false";
                    ErrorMessage = "There are no invoices for your account.";
                    handler.sendEmptyMessage(0);
                    return;
                }

                for (int i = 0; i < InvoiceCount; i++) {
                    JSONObject CurrentInvoice = null;
                    try {
                        CurrentInvoice = Invoices.getJSONObject(i);
                    } catch (JSONException e1) {
                        Log.e("APIFuncs", e1.getMessage());
                    }
                    try {
                        if (CurrentInvoice.getString("type").equals("invoice")) {
                            listOfInvoices.add(new Invoices(CurrentInvoice.getString("ref"),
                                    CurrentInvoice.getDouble("amount"), CurrentInvoice.getString("details"),
                                    CurrentInvoice.getString("date")));
                        } else {
                            Receipts.add(new Receipts(CurrentInvoice.getString("ref"),
                                    CurrentInvoice.getDouble("amount"), CurrentInvoice.getString("details"),
                                    CurrentInvoice.getString("date")));
                        }
                    } catch (JSONException e) {
                        Log.e("APIFuncs", e.getMessage());
                    }
                }
            }

            handler.sendEmptyMessage(0);
        }
    };

    dataPreload.start();
}