为什么我的应用程序没有从Android应用程序正确地将数据插入我的服务器?

时间:2017-01-07 04:21:46

标签: android mysql bluetooth phpmyadmin

我正在使用来自Android应用程序的数据,此数据在此信息发送到MySQL数据库之后加载一个列表,这些数据是图表的点。我注意到这些值不能很好地到达,因为这些值不能形成我需要的图形。 有时当我尝试访问数据库时,我有这个错误:

PhpMyAdmin Error 但我不明白这是什么?有没有人有这样的事情? 是服务器还是应用程序中的问题? 我认为这更像是服务器问题,因为当我检查列表的数据时,我将发送这些数据。

这是方法将数据发送到服务器的类:

package com.botonmedico.amunet.service;
import com.botonmedico.amunet.Login;
import com.botonmedico.amunet.model.UserModel;
import com.botonmedico.amunet.utils.HttpUtil;
import com.loopj.android.http.AsyncHttpResponseHandler;
import org.json.JSONArray;
import org.json.JSONObject;
public class ServiceManager2
{
public static void onLoginUser(String user,String pw,final Login activity)
{
    String url = Globals.baseUrl + "login.php"
            +"?user=" + user
            +"&pw=" + pw;

    HttpUtil.get(url, new AsyncHttpResponseHandler()
    {
        public void onFailure(Throwable paramThrowable) {
            String s = "fail";
        }

        public void onFinish() {
            String s = "finish";
        }

        public void onSuccess(String paramString)
        {  //that is return when success..
            System.out.println("Entrando al onSuccess");
            try
            {
                JSONObject localJSONObject1 = new JSONObject(paramString);
                if (localJSONObject1.has("response"))
                {
                    String response = localJSONObject1.getString("response");
                    if (response.equals("200"))
                    {
                        JSONArray jsArray = localJSONObject1.getJSONArray("users");
                        JSONObject model = jsArray.getJSONObject(0);
                        UserModel mModel = new UserModel();
                        mModel.mName = model.getString("user");
                        mModel.mId = model.getString("id");

                        int state = model.getInt("state");
                        if (state == 1)//
                        {
                            Globals.mAccount = mModel;
                            activity.iniciaApp();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                e.printStackTrace();
                activity.errorIniciarApp();
                activity.mDialogLogin.dismiss();
            }
        }
    });
}
//Funcion que envia los datos si las listas de datos no estan vacias
public static void onSendData()
{

    String valueECGGraph = "";
    String valueContadorECG="";
    String valueTiempoMS="";

    if(Globals.lstSendECGGraphData.size()>0)
        valueECGGraph = Globals.lstSendECGGraphData.get(0);
        Globals.lstSendECGGraphData.remove(0);/*********************/
        System.out.println("*Valor en lista ECG: "+valueECGGraph);
        //final String v_ECGGraphArduino = valueECGGraph;
    if(Globals.lstSendContadorECG.size()>0)
        valueContadorECG = Globals.lstSendContadorECG.get(0);
        Globals.lstSendContadorECG.remove(0);
        System.out.println("*Valor en lista Contador: "+valueContadorECG);
    if(Globals.lstSendSegundoECG.size()>0)
        valueTiempoMS = Globals.lstSendSegundoECG.get(0);
    Globals.lstSendSegundoECG.remove(0);
    System.out.println("*Valor en lista segundos: "+valueTiempoMS);

    //In this section will save the data to Database
    String url = Globals.baseUrl + "receiveData.php"
            +"?EcgGraphValue="+valueECGGraph
            +"&contadorECG="+valueContadorECG
            +"&TiempoECG="+valueTiempoMS
            +"&uid=" + Globals.mAccount.mId;
    HttpUtil.get(url, new AsyncHttpResponseHandler()
    {
        public void onFailure(Throwable paramThrowable) {
            String s = "fail";
        }

        public void onFinish() {
            String s = "finish";
        }
     //

        public void onSuccess(String paramString) {  //that is return when     success..
            try {
                JSONObject localJSONObject1 = new JSONObject(paramString);
                if (localJSONObject1.has("response")) {
                    String response = localJSONObject1.getString("response");
                    if (response.equals("200"))
                    {

                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

}

这是将数据加载到列表中的类的一部分:

if (charFinCadena > 0) {
            try {
                nombreDispositivo = readMessage.substring(charInicioCadena + 1, charInicioTiempo);

            switch (nombreDispositivo) {
                case "ecg":
                    cuenta++;
                    segundo = readMessage.substring(charInicioTiempo + 1, charInicioValor);
                    valorECG = readMessage.substring(charInicioValor + 1, charFinCadena);
                    System.out.println("Device: " + nombreDispositivo);
                    System.out.println("second: " + segundo);
                    System.out.println("Value: " + valorECG);
                    System.out.println("dato : " + cuenta);
                    System.out.println("******************************************************");

                    //Listas donde se agregan los valores obtenidos de las substrings
                    Globals.lstSendECGGraphData.add(valorECG);
                    Globals.lstSendContadorECG.add(String.valueOf(cuenta));
                    Globals.lstSendSegundoECG.add(segundo);

                    ServiceManager2.onSendData();
                    System.out.println("******************************************************");
                    ServiceManager.onSendData();
                    break;
                default:
                    break;
            }
        }catch(NullPointerException|StringIndexOutOfBoundsException ex){}
        }

如果您有任何问题或建议,请通过建议告诉我。

0 个答案:

没有答案