构建 android 应用程序:我可以将数据发送到本地主机中的数据库,但在线数据库中不一样
Building android app :I can sending data to database in localhost but not the same in online database
我对我的 android 应用程序中发生的事情有点困惑,因为我不明白为什么我可以使用我的 android 应用程序将数据发送到本地主机数据库,但我做不到在线数据库中的相同作业。最大的问题是找不到错误。
注意:我使用 volley=>(StringRequest) 向数据库发送数据
这是我的 class 我向数据库发送数据的请求:
public class MyRequest {
private Context context;
private RequestQueue queue;
public MyRequest(Context context, RequestQueue queue) {
this.context = context;
this.queue = queue;
}
public void register(final String nom, final String prenom,
final String naissance, final String telephone, final String email
, final String fonction
, final String commentaire, final String imagedata,
final RegistreCallback callback) {
String url =
"http://wided.epizy.com/index.php?controller=utilisateur&action=enregistrer";
StringRequest request = new StringRequest(Request.Method.POST
, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
callback.onSuccess("inscription validée");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (error instanceof NetworkError) {
callback.onError("Impossible de se connecter");
} else if (error instanceof VolleyError) {
callback.onError("une erreur s'est produite");
}
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> map = new HashMap<>();
map.put("nom", nom);
map.put("prenom", prenom);
map.put("naissance", naissance);
map.put("telephone", telephone);
map.put("email", email);
map.put("fonction", fonction);
map.put("commentaire", commentaire);
map.put("image", imagedata);
return map;
}
};
queue.add(request);
}
public interface RegistreCallback {
void onSuccess(String message);
void inputErrors(Map<String, String> errors);
void onError(String message);
}
}
输出日志:
2019-09-08 21:33:34.448 14735-14735/com.example.eventapp I/System.out: Sun Sep 08 21:33:34 GMT+01:00 2019
2019-09-08 21:33:34.449 14735-14735/com.example.eventapp W/System.err: java.text.ParseException: Unparseable date: "8"
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at java.text.DateFormat.parse(DateFormat.java:362)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at com.example.eventapp.Main2Activity.onClick(Main2Activity.java:227)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View.performClick(View.java:6597)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View.performClickInternal(View.java:6574)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View.access00(View.java:778)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View$PerformClick.run(View.java:25885)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.os.Handler.handleCallback(Handler.java:873)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.os.Looper.loop(Looper.java:193)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6669)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2019-09-08 21:33:34.456 14735-14908/com.example.eventapp D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
2019-09-08 21:33:35.305 14735-14735/com.example.eventapp W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@3a63de6
2019-09-08 21:33:35.820 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00)
2019-09-08 21:33:36.082 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00)
2019-09-08 21:33:36.184 14735-14764/com.example.eventapp I/chatty: uid=10087(com.example.eventapp) RenderThread identical 1 line
2019-09-08 21:33:36.222 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00)
2019-09-08 21:33:36.525 14735-14735/com.example.eventapp D/AutofillManager: onActivityFinishing(): calling cancelLocked()
2019-09-08 21:33:37.377 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00)
我认为您正在使用来自 infinityfree 网站的免费服务。
infinityfree 拒绝接受来自 android 应用程序的数据。
详情
https://infinityfree.net/support/javascript-error-using-api-or-mobile-android-app/
我对我的 android 应用程序中发生的事情有点困惑,因为我不明白为什么我可以使用我的 android 应用程序将数据发送到本地主机数据库,但我做不到在线数据库中的相同作业。最大的问题是找不到错误。
注意:我使用 volley=>(StringRequest) 向数据库发送数据
这是我的 class 我向数据库发送数据的请求:
public class MyRequest {
private Context context;
private RequestQueue queue;
public MyRequest(Context context, RequestQueue queue) {
this.context = context;
this.queue = queue;
}
public void register(final String nom, final String prenom,
final String naissance, final String telephone, final String email
, final String fonction
, final String commentaire, final String imagedata,
final RegistreCallback callback) {
String url =
"http://wided.epizy.com/index.php?controller=utilisateur&action=enregistrer";
StringRequest request = new StringRequest(Request.Method.POST
, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
callback.onSuccess("inscription validée");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (error instanceof NetworkError) {
callback.onError("Impossible de se connecter");
} else if (error instanceof VolleyError) {
callback.onError("une erreur s'est produite");
}
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> map = new HashMap<>();
map.put("nom", nom);
map.put("prenom", prenom);
map.put("naissance", naissance);
map.put("telephone", telephone);
map.put("email", email);
map.put("fonction", fonction);
map.put("commentaire", commentaire);
map.put("image", imagedata);
return map;
}
};
queue.add(request);
}
public interface RegistreCallback {
void onSuccess(String message);
void inputErrors(Map<String, String> errors);
void onError(String message);
}
}
输出日志:
2019-09-08 21:33:34.448 14735-14735/com.example.eventapp I/System.out: Sun Sep 08 21:33:34 GMT+01:00 2019 2019-09-08 21:33:34.449 14735-14735/com.example.eventapp W/System.err: java.text.ParseException: Unparseable date: "8" 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at java.text.DateFormat.parse(DateFormat.java:362) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at com.example.eventapp.Main2Activity.onClick(Main2Activity.java:227) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View.performClick(View.java:6597) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View.performClickInternal(View.java:6574) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View.access00(View.java:778) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.view.View$PerformClick.run(View.java:25885) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.os.Handler.handleCallback(Handler.java:873) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.os.Looper.loop(Looper.java:193) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6669) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at java.lang.reflect.Method.invoke(Native Method) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 2019-09-08 21:33:34.450 14735-14735/com.example.eventapp W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 2019-09-08 21:33:34.456 14735-14908/com.example.eventapp D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true 2019-09-08 21:33:35.305 14735-14735/com.example.eventapp W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@3a63de6 2019-09-08 21:33:35.820 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00) 2019-09-08 21:33:36.082 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00) 2019-09-08 21:33:36.184 14735-14764/com.example.eventapp I/chatty: uid=10087(com.example.eventapp) RenderThread identical 1 line 2019-09-08 21:33:36.222 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00) 2019-09-08 21:33:36.525 14735-14735/com.example.eventapp D/AutofillManager: onActivityFinishing(): calling cancelLocked() 2019-09-08 21:33:37.377 14735-14764/com.example.eventapp D/EGL_emulation: eglMakeCurrent: 0xe65ff7c0: ver 2 0 (tinfo 0xe65b1d00)
我认为您正在使用来自 infinityfree 网站的免费服务。
infinityfree 拒绝接受来自 android 应用程序的数据。
详情 https://infinityfree.net/support/javascript-error-using-api-or-mobile-android-app/