简体   繁体   中英

Internet Permissions?

I'm developing a mobile app and this one is not saving the data into the database. the app consume a web service and this one saves into the database. On the other clases all is working OK but in this, not. I don't know if that's because of permissions or another problem but i want a little big of help please. Sorry for my english may be is not to good.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ctorres.superagentemovil3">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<!-- android:icon="@mipmap/ic_launcher" -->
<!-- android:roundIcon="@mipmap/ic_launcher_round" -->
<application
    android:allowBackup="true"
    android:icon="@drawable/icono_agente"
    android:label="@string/app_name"
    android:roundIcon="@drawable/icono_agente"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".superagente.SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

</manifest>

this method calls the web service

@Override
public UsuarioEntity getClaveAcceso(String usuarioId, String claveAcceso, String pregunta, String segundaClaveAcceso) {
    UsuarioEntity user;
    try {
        user = new UsuarioEntity();

        String url = Constante.IPORHOST + "webApi_2/apigeneral/ApiGeneral/ValidarClave/?idcliente_usu=" + usuarioId + "&pass1_usu=" + claveAcceso + "&pregunta_usu=" + pregunta + "&respuesta_usu=" + segundaClaveAcceso;
        JSONArray arrayJason = utils.getJSONArrayfromURL(url);
        Log.e("Json", arrayJason.toString());
        if (arrayJason != null) {
            if (arrayJason.length() > 0) {                                       
                user.setCodCliente(usuarioId);
                user.setClaveAcceso(claveAcceso);
                user.setPregunta(pregunta);
                user.setSegundaClaveAcceso(segundaClaveAcceso);
            } else {
                user = null;
            }
        } else {
            user = null;
        }

    } catch (Exception e) {
        Log.getStackTraceString(e);
        user = null;
    }

    return user;
}

and this one is code on the class who calls invokes the method who consumes the web service

private class informacionTarjeta extends AsyncTask<String, Void, UsuarioEntity> {
    String respuesta = txt_seg_clave.getText().toString();
    String clave = txt_clave.getText().toString();
    String confirmclave = txt_comfirm_clave.getText().toString();

    @Override
    protected UsuarioEntity doInBackground(String... params) {
        UsuarioEntity user;
        try {
            SuperAgenteDaoInterface dao = new SuperAgenteDaoImplement();
            user = dao.getClaveAcceso(usuario.getUsuarioId(), clave, validaPregunta(), respuesta);
            //Log.e("idCliente", "CodCliente=" + user.getCodCliente() + ", usuarioId=" + usuario.getUsuarioId());
            //usuario.setClaveAcceso(user.getClaveAcceso());
        } catch (Exception e) {
            user = null;
            //flag_clic_ingreso = 0;
        }
        return user;
    }        
}

First of All, You have tested in the server side if the script is doing right?

Well test with Postman THE API CALLBACKS.

Second:

Use Json request from Server side.

if(jsonObject.has('state'=='2'))
{
Log.d(Error, "ERROR");
}else{
/*Inserted*/
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM