我让我的 Android 应用程序的用户能够在那里回复我的反馈。从技术上讲,我只是对我的 PHP 脚本进行 HTTP-Post,它作为存储反馈的数据库的连接器。
由于我的应用程序正在全球范围内扩展,我正面临多种语言的问题。我遇到了这种语言的问题:
Espagnol - España
Arabic - الØ&
Korean - 대한ë¯&f
Hungary - Magyarország
Turkey - Türkiye
Austria - Österreich
实施适用于全球各地的反馈系统的最佳实践是什么?
到目前为止,我做了一个 AsyncTask,它启动了一个为 HttpPost 提供动力的 HttpClient。有我的代码:
public class reqeust_online extends AsyncTask<Void, Integer, Boolean>
{
@Override
protected void onPostExecute(Boolean result)
{
}
@Override
protected Boolean doInBackground(Void... params)
{
int request_widget = 0;
if(((CheckBox)request_dialog.findViewById(R.id.chx_request_widget)).isChecked())
{
request_widget = 1;
}
int request_gallery = 0;
if(((CheckBox)request_dialog.findViewById(R.id.chx_request_gallery)).isChecked())
{
request_gallery = 1;
}
int request_sound = 0;
if(((CheckBox)request_dialog.findViewById(R.id.chx_request_sound)).isChecked())
{
request_sound = 1;
}
/* End */
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(URI.create((getResources().getString(R.string.url_request_send))));
try {
ArrayList<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("request_widget", request_widget +""));
nameValuePair.add(new BasicNameValuePair("request_gallery", request_gallery +""));
nameValuePair.add(new BasicNameValuePair("request_sound", request_sound +""));
nameValuePair.add(new BasicNameValuePair("request_custom", ((EditText)request_dialog.findViewById(R.id.edt_request)).getText().toString()));
// Debug information
nameValuePair.add(new BasicNameValuePair("device_country", Locale.getDefault().getDisplayCountry()));
nameValuePair.add(new BasicNameValuePair("device_language", Locale.getDefault().getLanguage()));
nameValuePair.add(new BasicNameValuePair("device_model", android.os.Build.MODEL));
nameValuePair.add(new BasicNameValuePair("device_manufacturer", android.os.Build.MANUFACTURER));
post.setEntity(new UrlEncodedFormEntity(nameValuePair, "UTF-8"));
HttpResponse response = client.execute(post);
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpURLConnection.HTTP_OK)
{
return true;
}
}
catch (Exception e) {}
return false;
}
}
这是我的 PHP 代码,它存储传输到我的 MysqlDB 中的值
connect_mysql();
$country = clean($_POST['device_country']);
$language = clean($_POST['device_language']);
$model = clean($_POST['device_model']);
$manufacturer = clean($_POST['device_manufacturer']);
$widget = clean($_POST['request_widget']);
$gallery = clean($_POST['request_gallery']);
$sound = clean($_POST['request_sound']);
$custom = clean($_POST['request_custom']);
mysql_query("INSERT INTO wm2014_request (widget,gallery,sound,custom,country,language,model,manufacturer) VALUES ('$widget','$gallery','$sound','$custom','$country','$language','$model','$manufacturer')") or die (http_response_code(204));
http_response_code(200);
function clean($str)
{
$str = @trim($str);
$str = htmlentities($str);
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
$str = mysql_real_escape_string($str);
$str = addslashes($str);
return $str;
}
我设置了 MySQL 数据库,utf8_general_ci
所以这应该不是问题。
你能帮助我吗?