0
I have an API 28 application that consumes Webservice and sends data by GET
using Json
, and I need a field EditText
which accepts Accents, but when it arrives in the database it only records up to one letter before the first accent.
• Structure of the Phpmyadmin bank:
• A record inserted, I put the name: ASI. it records only the letter a.
Man Layout
where is the EditText
where I enter the record:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#ffffff"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Deixe seu Comentário:"
android:textColor="#548ddf"
android:textSize="18dp" />
<!-- Meu EditText -->
<EditText
android:id="@+id/txt_Mensagem_sat_email"
android:layout_width="250dp"
android:layout_height="100dp"
android:layout_marginTop="0dp"
android:background="#d8d6d3"
android:gravity="top|left"
android:hint="Comente aqui"
android:inputType="textMultiLine"
android:lines="6"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:scrollHorizontally="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="10sp"
android:gravity="center_horizontal|center_vertical">
<Button
android:id="@+id/btn_satisfacao_cancela"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="@drawable/botaoconsultar"
android:text="Cancelar"
android:textSize="14sp"
android:textStyle="italic" />
<Button
android:id="@+id/btn_satisfacao_enviar"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_marginStart="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="@drawable/botaoconsultar"
android:text="Enviar"
android:textSize="14sp"
android:textStyle="italic" />
</LinearLayout>
</LinearLayout>
My Method of Sending:
private void inserirWEBService() {
String url = "http://www.meusite.com.br/pasta/insereAvalia.php?linha=" + vCidade + "&horario=" + vHorario + "&sentido=" + vSentido + "&satisfacao=" + vSatisfacao + "&mensagem=" + vMensagemSatEmail;
url = url.replace(" ", "%20");
jsonObjectReq = new JsonObjectRequest(Request.Method.GET, url, null, this, this);
request.add(jsonObjectReq);
}
Here my upload PHP file:
<?php
ini_set('default_charset', 'UTF-8');
include "conexao.php";
$jason = array();
if(isset($_GET["linha"]) && isset($_GET["horario"]) && isset($_GET["sentido"]) && isset($_GET["satisfacao"]) && isset($_GET["mensagem"]) ){
$linha = $_GET["linha"];
$horario = $_GET["horario"];
$sentido = $_GET["sentido"];
$satisfacao = $_GET["satisfacao"];
$mensagem = $_GET["mensagem"];
$inserir = "INSERT INTO avalieviagem (linha, horario, sentido, satisfacao, mensagem)
VALUES ('{$linha}', '{$horario}', '{$sentido}', '{$satisfacao}', '{$mensagem}')";
$resultado_inserir = mysqli_query($conexao, $inserir);
}
?>
And my Encoding is like UTF-8 down in android studio. I don’t know what else to do.
Your problem probably happens because the URL is not escaped. But I would refactor this code to make this request via POST and the data as JSON in the request body.
– Leonardo Lima
How would you do that?
– Ari Melo
@Leonardolima was just that, I made the request via POST and it worked, as closure the call?
– Ari Melo