我做了一个学校项目,我在网上将图像作为blob插入到MySQL中,我将该图像提取到Android应用程序,然后在用ImageView
解码后将图像设置为base64
,问题是这个过程导致应用程序冻结并需要很长时间才能在Android中显示它,有时手机响应超过两分钟,我不知道该怎么做,我的代码中没有任何错误{ {1}}也不在PHP
。请帮助我并告诉我我能做些什么,以更快更有效地显示这个图像。谢谢
php代码:
Java android
访问以上功能:
...
public function StudentsOfParent($mobile){
$stmt = $this->conn->prepare("SELECT
a.id,
a.name,
a.mobile,
c.id as sutdentId,
c.user_id,
c.full_name,
c.school,
c.level,
c.year,
c.photo,
d.id as busId,
d.bus_name as plate_no,
e.id as DriverId,
e.driverphone_number,
e.driver_fullname
from users a
join students c
on a.id = c.user_id
join buses d
on c.id = d.student_id
join drivers e
on e.id = d.driver_id where a.mobile= ?");
$stmt->bind_param("i", $mobile);
if ($stmt->execute()) {
$result = $stmt->get_result();
$usersArr = $result->fetch_all(MYSQLI_ASSOC);
$stmt->close();
$result->free(); //Because why not?
return array_map(function ($user) {
$user['photo'] = base64_encode($user['photo']);
return $user;
}, $usersArr);
} else {
return NULL;
}
...
用于将图片传输到界面的Android代码:
....
if (isset($_POST['mobile'])){
$mobile = $_POST['mobile'];
$usersArr = $db->StudentsOfParent($mobile);
if ($usersArr != false) {
$response["error"]= FALSE;
$response["user"] = $usersArr;
echo json_encode($response);
.....