- 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/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!