سلام دوستان من تازه برنامه نویسی آندروید رو شروع کردم و در اجرای یه برنامه که می خواد عکس و متن رو از دیتابیس mysql بخونه بوسیله JSON به مشکل برخوردم البته برنامه خطا نداره ولی موقع لود اطلاعات کرش میکنه و خارج میشه.

اینم اضافه کنم ورژن آندرید من 3.1.2 هست و از گردل 4.4 استفاده میکنم و build.gradle من اینه:
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.farshid.appand"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunne r"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
[/CODE]
و یه دیتابیس داخل gigfa ساختم و اسم دیتابیسم gigfa_22018905_sampleDB و یه جدول دارم با 3 فیلد یid, AndroidNames, ImagePath
و اضافه کنم که فایل connection.php :

<?php
$servername ="sql207.gigfa.com";//replace it with your database server name
$username ="gigfa_22018905";//replace it with your database username
$password ="farshid";//replace it with your database password
$dbname ="gigfa_22018905_sampleDB";
// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
//if (!$con) {
// die("Connection failed: " . mysqli_connect_error());
//}
?>

فایل getandroidosnames.php :

<?php
require_once('connection.php');
$sql ="SELECT * FROM androidosnames";
$r = mysqli_query($con,$sql);
$result = array();
while($res = mysqli_fetch_array($r)){
array_push($result,array(
"AndroidNames"=>$res['AndroidNames'],
"ImagePath"=>$res['ImagePath']
)
);
}
echo json_encode(array("result"=>$result));
mysqli_close($con);
exit();
?>

و سه تا فایل جاوا دارم که به ترتیب: Customadapter.java

import android.app.Activity;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Created by Shree on 10/25/2016.
*/

publicclassCustomadapter extends ArrayAdapter<String>{
privateString[] androidosnames;
privateString[] urls;
privateBitmap[] bitmaps;
privateActivity context;
publicCustomadapter(Activity context,String[] androidosnames,Bitmap[] bitmaps ){
super
(context, R.layout.layout, androidosnames);
this.context = context;
// this.urls = urls;
this.bitmaps = bitmaps;
this.androidosnames = androidosnames;
}
@Override
publicView getView(int position,View convertView,ViewGroup parent){
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.layout,null,true);
TextView androidos =(TextView) listViewItem.findViewById(R.id.tvandroidosnames);
// TextView textView = (TextView) listViewItem.findViewById(R.id.tvurl);
// textView.setText(urls[position] );
androidos
.setText(androidosnames[position]);
ImageView image =(ImageView) listViewItem.findViewById(R.id.imgvw);
image
.setImageBitmap(Bitmap.createScaledBitmap(bitmaps[position],100,50,false));
return listViewItem;
}
}