- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
下面的代码将实现一个简单的在线登录系统。
php 脚本路径在常量 authenticationURL
中定义(MainActivity.java 中的第 34 行)。它已经过 Postman 测试,可以正常工作。loginButton
及其 onClick()
方法也可以正常工作,因为 Toast
嘿,我在这里! 显示。
但是无论输入字段的值是否有效,当单击/点击 loginButton
时,始终会显示 Toast
。这意味着 StringRequest
是 null
。
使用的工具:xampp 7.2.11-0-VC15、Android Studio 3.2.1 和 Genymotion 3.0.0 -> 自定义电话 (API 28)
MainActivity.java
package com.example.admin.test;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
private EditText usernameEditText, passwordEditText;
private static final String TAG = "OneTwoThree";
private RequestQueue requestQueue;
private StringRequest request;
private static final String authenticationURL = "http://10.0.3.2:80/test/authenticationScript.php";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
usernameEditText = findViewById(R.id.usernameEditText);
passwordEditText = findViewById(R.id.passwordEditText);
Button loginButton = findViewById(R.id.loginButton);
requestQueue = Volley.newRequestQueue(this);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
request = new StringRequest(Request.Method.POST, authenticationURL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
if(jsonObject.names().get(0).equals("success")) {
Toast.makeText(getApplicationContext(), "SUCCESS" + jsonObject.getString("success"), Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
} else {
Toast.makeText(getApplicationContext(), "ERROR" + jsonObject.getString("error"), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, "Request response error.");
Toast.makeText(getApplicationContext(), "Hey, I'm up here!" , Toast.LENGTH_LONG).show(); // Just for debugging purpose
}
})
{
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=UTF-8";
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("username", usernameEditText.getText().toString());
hashMap.put("password", passwordEditText.getText().toString());
return hashMap;
}
};
requestQueue.add(request);
}
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/usernameEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="8dp"
android:autofillHints="@string/username"
android:ems="10"
android:hint="@string/username"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:targetApi="o" />
<EditText
android:id="@+id/passwordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="8dp"
android:autofillHints="@string/password"
android:ems="10"
android:hint="@string/password"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/usernameEditText"
tools:targetApi="o" />
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="56dp"
android:layout_marginEnd="8dp"
android:text="@string/log_in"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/passwordEditText" />
</android.support.constraint.ConstraintLayout>
这是 Logcat 的部分(对不起,由于文本限制被截断了):
2019-01-11 21:45:41.731 248-248/? E/hostapd: Configuration file: /vendor/etc/simulated_hostapd.conf
2019-01-11 21:45:41.735 248-248/? E/hostapd: Using interface wlan1 with hwaddr 02:00:00:00:01:00 and ssid "AndroidWifi"
2019-01-11 21:45:41.736 134-134/? E/SELinux: avc: denied { add } for interface=android.hardware.wifi.hostapd::IHostapd pid=248 scontext=u:r:execns:s0 tcontext=u:object_r:hal_wifi_hostapd_hwservice:s0 tclass=hwservice_manager permissive=1
2019-01-11 21:45:41.737 134-134/? E/SELinux: avc: denied { add } for interface=android.hidl.base::IBase pid=248 scontext=u:r:execns:s0 tcontext=u:object_r:hidl_base_hwservice:s0 tclass=hwservice_manager permissive=1
2019-01-11 21:45:42.155 320-320/? E/Netd: cannot find interface dummy0
2019-01-11 21:45:42.155 320-320/? E/XfrmController: netlink response contains error (Status[code: 95, msg: "[Operation not supported on transport endpoint] : Error netlink message"])
2019-01-11 21:45:42.155 320-320/? E/Netd: Failed to initialize XfrmController (Status[code: 95, msg: "[Operation not supported on transport endpoint] : Error netlink message"])
2019-01-11 21:45:42.155 320-320/? E/Netd: Unable to create netlink socket: Protocol not supported
2019-01-11 21:45:43.031 321-321/? E/ActivityRecognitionHardware: activity_recognition HAL is deprecated. class_init is effectively a no-op
2019-01-11 21:45:43.672 351-351/system_process E/UsbAlsaJackDetectorJNI: Can't register UsbAlsaJackDetector native methods
2019-01-11 21:45:43.798 351-370/system_process E/BluetoothAdapter: Bluetooth binder is null
2019-01-11 21:45:43.799 351-370/system_process E/BatteryExternalStatsWorker: no controller energy info supplied for telephony
2019-01-11 21:45:50.229 400-400/? E/EmulatedCamera_Factory: 2 cameras are being emulated. 0 of them are fake cameras.
2019-01-11 21:45:50.229 400-400/? E/EmulatedCamera_HotplugThread: createFileIfNotExists: Could not create file '/data/misc/media/emulator.camera.hotplug.0', error: 'Permission denied' (13)
2019-01-11 21:45:50.229 400-400/? E/EmulatedCamera_HotplugThread: createFileIfNotExists: Could not create file '/data/misc/media/emulator.camera.hotplug.1', error: 'Permission denied' (13)
2019-01-11 21:45:50.230 400-400/? E/CamProvider@2.4-impl: setUpVendorTags: Vendor tag operations not fully defined. Ignoring definitions.
2019-01-11 21:45:50.230 400-400/? E/CamProvider@2.4-impl: initialize: Vendor tag setup failed, will not be available.
2019-01-11 21:45:50.264 399-399/? E/SoundTriggerHalImpl: couldn't load sound trigger module sound_trigger.primary (No such file or directory)
2019-01-11 21:45:50.294 417-417/? E/network_profile_handler: init_all_network_profile_state: wlan: wlan0 phone:rmnet0
2019-01-11 21:45:50.472 408-408/? E/light: light_open lights bluetooth failed: -22
2019-01-11 21:45:50.472 408-408/? E/light: Light passthrough failed to load legacy HAL.
2019-01-11 21:45:50.472 408-408/? E/light: light_open lights wifi failed: -22
2019-01-11 21:45:50.472 408-408/? E/light: Light passthrough failed to load legacy HAL.
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type audio/x-ape
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type audio/ffmpeg
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type video/divx
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type audio/vnd.dts
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type video/x-flv
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type audio/vnd.rn-realaudio
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type video/vnd.rn-realvideo
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type video/vc1
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type video/ffmpeg
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type audio/x-ms-wma
2019-01-11 21:45:50.520 442-442/? E/MediaCodecsXmlParser: Cannot find the role for a decoder of type video/x-ms-wmv
2019-01-11 21:45:50.634 406-406/? E/hwcomposer: unknown display attribute 6
2019-01-11 21:45:50.674 429-429/? E/ExtCamUtils@3.4: loadFromCfg: Unable to load external camera config file '/vendor/etc/external_camera_config.xml'. Error: XML_ERROR_FILE_NOT_FOUND
2019-01-11 21:45:50.677 429-429/? E/CameraProviderManager: filterLogicalCameraIdsLocked: Failed to getCameraCharacteristics for id 0
2019-01-11 21:45:50.681 399-468/? E/EffectsConfig: Could not parse effect configuration in any of the default locations.
2019-01-11 21:45:50.681 399-468/? E/EffectsFactoryConfigLoader: Failed to parse XML configuration file
2019-01-11 21:45:50.683 429-429/? E/CameraProviderManager: filterLogicalCameraIdsLocked: Failed to getCameraCharacteristics for id 0
2019-01-11 21:45:50.684 429-476/? E/CameraProviderManager: filterLogicalCameraIdsLocked: Failed to getCameraCharacteristics for id 0
2019-01-11 21:45:50.684 429-429/? E/CameraProviderManager: filterLogicalCameraIdsLocked: Failed to getCameraCharacteristics for id 0
2019-01-11 21:45:50.685 429-476/? E/CameraService: onDeviceStatusChanged: State transition to the same status 0x1 not allowed
2019-01-11 21:45:50.695 413-413/? E/EffectsConfig: Could not parse effect configuration in any of the default locations.
2019-01-11 21:45:50.795 419-419/? E/libEGL: load_driver(/vendor/lib/egl/libGLES_emulation.so): dlopen failed: library "/vendor/lib/egl/libGLES_emulation.so" not found
2019-01-11 21:45:50.934 419-419/? E/HWComposer: getSupportedPerFrameMetadata: getSupportedPerFrameMetadata failed for display 0: Unsupported (8)
2019-01-11 21:45:52.438 351-376/system_process E/LocalDisplayAdapter: Default and active color mode is no longer available! Reverting to first available mode.
2019-01-11 21:45:52.507 534-539/? E/libEGL: load_driver(/vendor/lib/egl/libGLES_emulation.so): dlopen failed: library "/vendor/lib/egl/libGLES_emulation.so" not found
2019-01-11 21:45:52.850 351-351/system_process E/PackageManager: There should probably be a verifier, but, none were found
2019-01-11 21:45:52.889 413-413/? E/SoundTriggerHwService: could not read implementation properties
2019-01-11 21:45:52.976 351-364/system_process E/SystemServer: Unable to preload default resources
2019-01-11 21:45:53.009 351-351/system_process E/VibratorService: vibratorOff command failed (1).
2019-01-11 21:45:53.219 351-590/system_process E/EventHub: could not get driver version for /dev/input/mouse0, Not a typewriter
2019-01-11 21:45:53.291 145-145/? E/vold: Failed to read field SystemLocale: No such file or directory
2019-01-11 21:45:53.322 351-592/system_process E/StorageManagerService: Failed to read field SystemLocale
android.os.ServiceSpecificException: Failed to read field SystemLocale (code 2)
at android.os.Parcel.createException(Parcel.java:1956)
at android.os.Parcel.readException(Parcel.java:1910)
at android.os.Parcel.readException(Parcel.java:1860)
at android.os.IVold$Stub$Proxy.fdeGetField(IVold.java:1094)
at com.android.server.StorageManagerService.getField(StorageManagerService.java:2408)
at com.android.server.StorageManagerService.copyLocaleFromMountService(StorageManagerService.java:982)
at com.android.server.StorageManagerService.handleDaemonConnected(StorageManagerService.java:975)
at com.android.server.StorageManagerService.access$900(StorageManagerService.java:171)
at com.android.server.StorageManagerService$StorageManagerServiceHandler.handleMessage(StorageManagerService.java:572)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
2019-01-11 21:45:53.350 351-590/system_process E/EventHub: could not get driver version for /dev/input/mice, Not a typewriter
2019-01-11 21:45:53.543 351-351/system_process E/WifiStateMachine: getWifiLinkLayerStats called without an interface
2019-01-11 21:45:53.555 351-351/system_process E/SupplicantStaIfaceHal: Can't call setDebugParams, ISupplicant is null
2019-01-11 21:45:53.642 351-351/system_process E/UsbPortManager: connectToProxy: usb hal service not found. Did the service fail to start?
java.util.NoSuchElementException
at android.os.HwBinder.getService(Native Method)
at android.os.HwBinder.getService(HwBinder.java:91)
at android.hardware.usb.V1_0.IUsb.getService(IUsb.java:48)
at android.hardware.usb.V1_0.IUsb.getService(IUsb.java:52)
at com.android.server.usb.UsbPortManager.connectToProxy(UsbPortManager.java:531)
at com.android.server.usb.UsbPortManager.<init>(UsbPortManager.java:137)
at com.android.server.usb.UsbService.<init>(UsbService.java:142)
at com.android.server.usb.UsbService$Lifecycle.onStart(UsbService.java:73)
at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:126)
at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:113)
at com.android.server.SystemServiceManager.startService(SystemServiceManager.java:72)
at com.android.server.SystemServer.startOtherServices(SystemServer.java:1308)
at com.android.server.SystemServer.run(SystemServer.java:432)
at com.android.server.SystemServer.main(SystemServer.java:295)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:838)
2019-01-11 21:45:53.646 351-351/system_process E/HardwarePropertiesManagerService-JNI: Unable to get Thermal service.
2019-01-11 21:45:53.718 351-351/system_process E/LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/gatekeeper.password.key: open failed: ENOENT (No such file or directory)
2019-01-11 21:45:53.718 351-351/system_process E/LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/password.key: open failed: ENOENT (No such file or directory)
2019-01-11 21:45:53.718 351-351/system_process E/LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/gatekeeper.pattern.key: open failed: ENOENT (No such file or directory)
2019-01-11 21:45:53.719 351-351/system_process E/LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/gatekeeper.gesture.key: open failed: ENOENT (No such file or directory)
2019-01-11 21:45:53.719 351-351/system_process E/LockSettingsStorage: Cannot read file java.io.FileNotFoundException: /data/system/gesture.key: open failed: ENOENT (No such file or directory)
2019-01-11 21:45:53.754 351-351/system_process E/IpConfigStore: Error opening configuration file: java.io.FileNotFoundException: /data/misc/ethernet/ipconfig.txt (No such file or directory)
2019-01-11 21:45:53.855 351-351/system_process E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /data/system/users/0/wallpaper_orig (No such file or directory)
2019-01-11 21:45:53.855 351-351/system_process E/WallpaperManagerService: Unable to apply new wallpaper
2019-01-11 21:45:53.865 351-614/system_process E/BluetoothAdapter: Bluetooth binder is null
2019-01-11 21:45:53.866 351-614/system_process E/BluetoothAdapter: Bluetooth binder is null
2019-01-11 21:45:53.933 436-457/? E/MediaExtractorFactory: couldn't opendir(/vendor/lib/extractors)
2019-01-11 21:45:53.972 351-370/system_process E/BatteryExternalStatsWorker: no controller energy info supplied for wifi
2019-01-11 21:45:53.972 351-370/system_process E/BatteryExternalStatsWorker: no controller energy info supplied for telephony
2019-01-11 21:45:53.991 320-342/? E/IptablesRestoreController: iptables error:
------- COMMAND -------
*filter
-I bw_INPUT -m quota2 ! --quota 2097152 --name globalAlert
-I bw_OUTPUT -m quota2 ! --quota 2097152 --name globalAlert
COMMIT
------- ERROR -------
iptables-restore: line 290 failed
----------------------
2019-01-11 21:45:54.003 320-342/? E/IptablesRestoreController: iptables error:
------- COMMAND -------
*filter
-I bw_INPUT -m quota2 ! --quota 2097152 --name globalAlert
-I bw_OUTPUT -m quota2 ! --quota 2097152 --name globalAlert
COMMIT
------- ERROR -------
ip6tables-restore: line 271 failed
----------------------
2019-01-11 21:45:54.048 672-690/? E/WebViewLoader-: Failed to send DDMS packet REAQ to debugger (-1 of 20): Broken pipe
2019-01-11 21:45:54.061 442-442/? E/media.codec: Failed to allocate omx component 'OMX.google.ac3.decoder' err=InvalidComponentName(0x80001002)
2019-01-11 21:45:54.063 320-342/? E/BandwidthController: Updating quota globalAlert failed (Status[code: 2, msg: "[No such file or directory] : fopen("/proc/net/xt_quota/globalAlert", "we") failed"])
2019-01-11 21:45:54.072 404-404/? E/GnssHAL_GnssInterface: getExtensionAGnss: AGnss interface not implemented by HAL
2019-01-11 21:45:54.072 404-404/? E/GnssHAL_GnssInterface: getExtensionGnssMeasurement: GnssMeasurement interface not implemented by HAL
2019-01-11 21:45:54.072 404-404/? E/GnssHAL_GnssInterface: getExtensionGnssConfiguration: GnssConfiguration interface not implemented by HAL
2019-01-11 21:45:54.072 404-404/? E/GnssHAL_GnssInterface: getExtensionGnssGeofencing: GnssGeofencing interface not implemented by HAL
2019-01-11 21:45:54.073 404-404/? E/GnssHAL_GnssInterface: gnss flp hw_get_module failed: -2
2019-01-11 21:45:54.073 404-404/? E/GnssHAL_GnssInterface: getExtensionGnssBatching: GnssBatching interface is not implemented by HAL
2019-01-11 21:45:54.111 351-351/system_process E/LocationManagerService: no geocoder provider found
2019-01-11 21:45:54.127 351-351/system_process E/ActivityRecognitionHardware: activity_recognition HAL is deprecated. is_supported is effectively a no-op
2019-01-11 21:45:54.128 351-351/system_process E/ActivityRecognitionProxy: ServiceWatcher could not start.
2019-01-11 21:45:54.128 351-365/system_process E/GnssLocationProvider: Unable to initialize GNSS Xtra interface
2019-01-11 21:45:54.132 351-365/system_process E/GnssLocationProvider: no AGPS interface in set_agps_server
2019-01-11 21:45:54.167 351-365/system_process E/GnssLocationProvider: Unable to initialize GNSS Xtra interface
2019-01-11 21:45:54.167 351-365/system_process E/GnssLocationProvider: no AGPS interface in set_agps_server
2019-01-11 21:45:54.167 351-365/system_process E/GnssBatchingProvider: Failed to initialize GNSS batching
2019-01-11 21:45:54.173 442-442/? E/media.codec: Failed to allocate omx component 'OMX.google.mp2.decoder' err=InvalidComponentName(0x80001002)
2019-01-11 21:45:54.231 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.h264.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.231 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.h264.decoder, OMX.google.android.index.enableAndroidNativeBuffers) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.237 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.h263.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.237 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.h263.decoder, OMX.google.android.index.enableAndroidNativeBuffers) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.244 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.hevc.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.244 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.hevc.decoder, OMX.google.android.index.enableAndroidNativeBuffers) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.248 442-442/? E/media.codec: Failed to allocate omx component 'OMX.google.mpeg2v.decoder' err=InvalidComponentName(0x80001002)
2019-01-11 21:45:54.250 442-442/? E/OMXNodeInstance: getExtensionIndex(0xea42cba0:google.mpeg4.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.250 442-442/? E/OMXNodeInstance: getExtensionIndex(0xea42cba0:google.mpeg4.decoder, OMX.google.android.index.enableAndroidNativeBuffers) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.257 442-442/? E/OMXNodeInstance: getExtensionIndex(0xea42cba0:google.vp8.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.257 442-442/? E/OMXNodeInstance: getExtensionIndex(0xea42cba0:google.vp8.decoder, OMX.google.android.index.enableAndroidNativeBuffers) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.265 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.vp9.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.265 442-456/? E/OMXNodeInstance: getExtensionIndex(0xea42c8a0:google.vp9.decoder, OMX.google.android.index.enableAndroidNativeBuffers) ERROR: UnsupportedIndex(0x8000101a)
2019-01-11 21:45:54.290 442-456/? E/OMXNodeInstance: getConfig(0xea42cba0:google.h263.encoder, ConfigAndroidIntraRefresh(0x6f60000a)) ERROR: Undefined(0x80001001)
2019-01-11 21:45:54.300 442-456/? E/OMXNodeInstance: getConfig(0xea42cba0:google.mpeg4.encoder, ConfigAndroidIntraRefresh(0x6f60000a)) ERROR: Undefined(0x80001001)
2019-01-11 21:45:54.317 442-456/? E/OMXNodeInstance: getConfig(0xea42cba0:google.vp8.encoder, ConfigAndroidIntraRefresh(0x6f60000a)) ERROR: Undefined(0x80001001)
2019-01-11 21:45:54.382 442-442/? E/OMXNodeInstance: getConfig(0xea42c900:google.vorbis.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
2019-01-11 21:45:54.551 442-456/? E/OMXNodeInstance: getConfig(0xea42c900:google.vorbis.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
2019-01-11 21:45:54.667 442-456/? E/OMXNodeInstance: getConfig(0xea42c900:google.vorbis.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
2019-01-11 21:45:54.679 767-767/? E/wpa_supplicant: global ctrl interface @android:wpa_wlan0 matches ctrl interface wlan0 - do not open per-interface ctrl interface
2019-01-11 21:45:54.690 767-767/? E/wpa_supplicant: global ctrl interface @android:wpa_wlan0 matches ctrl interface wlan0 - do not open per-interface ctrl interface
2019-01-11 21:45:54.724 634-819/com.android.inputmethod.latin E/ActivityThread: Failed to find provider info for user_dictionary
2019-01-11 21:45:54.863 412-412/? E/android.hardware.wifi@1.0-service: Failed to register radio mode change callback
2019-01-11 21:45:54.863 412-412/? E/android.hardware.wifi@1.0-service: Failed to set DFS flag; DFS channels may be unavailable.
2019-01-11 21:45:54.923 441-441/? E/wificond: No Offload Service available
2019-01-11 21:45:55.049 769-769/? E/CarrierIdProvider: read carrier list from ota pb failure: java.io.FileNotFoundException: /data/misc/carrierid/carrier_list.pb (No such file or directory)
2019-01-11 21:45:55.050 781-822/? E/libEGL: load_driver(/vendor/lib/egl/libGLES_emulation.so): dlopen failed: library "/vendor/lib/egl/libGLES_emulation.so" not found
2019-01-11 21:45:55.276 351-604/system_process E/SupplicantStaIfaceHal: Can't call setupIface, ISupplicantStaIface is null
2019-01-11 21:45:55.578 351-351/system_process E/BluetoothAdapter: Bluetooth binder is null
2019-01-11 21:45:55.859 442-456/? E/OMXNodeInstance: getConfig(0xea42c9c0:google.vorbis.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.admin.test">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
最佳答案
当您使用表单数据时,您必须添加 x-www-form-urlencoded。这样做:
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=UTF-8";
}
您的代码将类似于以下代码:
public class MainActivity extends AppCompatActivity {
private EditText usernameEditText, passwordEditText;
private RequestQueue requestQueue;
private StringRequest request;
private static final String authenticationURL = "http://10.0.3.2:80/test/authenticationScript.php";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
usernameEditText = findViewById(R.id.email);
passwordEditText = findViewById(R.id.password);
Button logIn = findViewById(R.id.signInUp);
requestQueue = Volley.newRequestQueue(this);
logIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Just for debugging purpose
Toast.makeText(getApplicationContext(), "Hey, I'm up here!" , Toast.LENGTH_LONG).show();
request = new StringRequest(Request.Method.POST, authenticationURL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
if(jsonObject.names().get(0).equals("success")) {
Toast.makeText(getApplicationContext(), "SUCCESS" + jsonObject.getString("success"), Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), NextActivity.class));
} else {
Toast.makeText(getApplicationContext(), "ERROR" + jsonObject.getString("error"), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=UTF-8";
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("username", usernameEditText.getText().toString());
hashMap.put("password", passwordEditText.getText().toString());
return hashMap;
}
};
requestQueue.add(request);
}
});
}
关于android - Volley 的 StringRequest 没有返回 JSONObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54152093/
我想使用 Volley StringRequest 将 base64 编码的图像和一些文本上传到我的网络服务器。 当我直接尝试发送 base64 字符串时,我得到“意外响应代码 503”,但是当我压缩
我有一些从谷歌应用程序脚本接收数据的方法,但为所有方法放置相同的代码有点长。 例如,这是我的 checkIn 方法,但我需要创建 checkOut 方法或 UpdateReservation 来从 g
我正在使用 android volley ,我想用 stringRequest 发送发布数据。但参数不发送到服务器。这是我的代码: StringRequest jsonObjReq =
我是 Android 的新手,我希望得到有关 StringRequestVolley 的帮助。在我的项目中,我将调用多个 API。为此,我创建了一个名为 ProcessAPIRequest 的方法。为
我正在尝试使用 Volley 发送请求,但我不知道如何让它工作。 我需要发送一个以 JSON 编码数据作为正文的 POST 请求,但在尝试了数小时不同的方法后,我仍然无法让它工作。 这是我当前的请求代
我对应该使用哪个感到有点困惑。 尽管其响应是 JSON 字符串,但该 API 试图接受常规文本发布参数。 我应该使用哪个? 最佳答案 为此,您可以使用 JSON 对象请求。 关于android - 我
我用过this简单的获取请求代码 final StringBuilder result = new StringBuilder(); RequestQueue queue = Voll
我正在创建一个按钮,单击该按钮会调用 checkUserName 方法,该方法会搜索数据库并告知用户名是否可用。 URL_CHECK_USERNAME 响应“用户名可用”或“用户名不可用”。
我已经放置了这个依赖项使用 volley 并从受尊重的 URl 获取 JSON 数据:- **compile 'me.neavo:volley:2014.12.09'** 放置此后没有得到 Strin
我正在尝试从 Android 发出 POST 请求以在我的 phpmyadmin 中插入一些信息。 我在用什么 Slim 与存储在 phpmyadmin 的数据库建立连接和查询。 XAMPP 模拟本地
我的 Volley 代码曾经像这样正常工作: StringRequest stringRequest = new StringRequest(method, URL, listener, errorL
下面的代码将实现一个简单的在线登录系统。 php 脚本路径在常量 authenticationURL 中定义(MainActivity.java 中的第 34 行)。它已经过 Postman 测试,可
api 调用发送了正确的响应,但是当我从 Volley StringRequest 得到响应时,撇号符号更改为不可读的字符。 我用来进行 api 调用的代码是这样的: private fun make
我已经能够使用 volley 从 url 获取字符串。该字符串现在在 TextView 中显示为一个 block 。但我希望能够在单独的 TextView 中显示这些数据。我怎样才能做到这一点? 也许
我正在使用以下代码在我服务器上的 sql 数据库中注册用户。 package com.cc.envoycc.activity; import android.app.Activity; import
我目前正在 fragment 内处理 ListView 。它工作得很好,但我需要使用用户的用户名过滤 ListView 上的数据。我如何能够使用请求传递“用户名”?任何帮助、建议和提示将不胜感激。预先
我试图通过在 Android 中使用 StringRequest 以及 POST 方法来获取 JSONArray。 php脚本的写法如下: $statement = mysqli_prepare($c
我有以下代码可以调用和接收 xml。 StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
当我在调试器中运行该方法时,数据按预期显示,但是每当我尝试使用它执行任何操作时,parentObject 的值都会返回为 null。 我只是想从服务器获取响应并将其存储为 JSONObject 以便在
我正在使用 Android Volley 进行网络通话。一般我使用JSONRequest接收json数据,然后使用GSON将它们转换成对象。 new Response.Listener() {
我是一名优秀的程序员,十分优秀!