Hello,
in my app, i display in "ImageView" widget an image get by url.
When i launch my app in debug mode in my tablet (android 4.0.3), it is ok, i have the image displayed correctly.
But when i launch it in my phones (android 6 and android 5), the image isn't display and in the logcat i don't have errors neither warnings.
Here it's the source code of the activity (source java) and xml
here it is the xml code:
Please could you help me?
Thanks for advance,
in my app, i display in "ImageView" widget an image get by url.
When i launch my app in debug mode in my tablet (android 4.0.3), it is ok, i have the image displayed correctly.
But when i launch it in my phones (android 6 and android 5), the image isn't display and in the logcat i don't have errors neither warnings.
Here it's the source code of the activity (source java) and xml
Java:
public class display_ofr extends AppCompatActivity implements IMessage {
private TextView TextLibelle;
private TextView TextDescription;
private ImageView imgView;
private JSONArray fURLImagesbyOfer = null;
private static final String GET_IMAGES_BY_OFER = "http://xxxxx";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_offer);
TextLibelle = (TextView)findViewById(R.id.textView4);
TextDescription = (TextView)findViewById(R.id.textView5);
imgView = (ImageView)findViewById(R.id.imageView);
Intent thisIntent = this.getIntent();
Bundle b = thisIntent.getExtras();
if(b!=null){
String j =(String) b.get(Constants.TAG_LIBELLE);
TextLibelle.setText(j);
TextDescription.setText(j+"\n"+(String)b.get(Constants.TAG_DESCRPTION));
String offerID = (String)b.get(Constants.TAG_IDOFR);
/**here i used an asynchron task to get the url in a database*/
SignupActivity r = new SignupActivity(this,null,GET_IMAGES_BY_OFFER, null);
r.fOff = this;
r.execute("" + offerID);
}
}
@Override
public void getOffersResultPostExecute(JSONArray pURLImagesbyOffer) {
fURLImagesbyOffer = pURLImagesbyOffer;
try {
String[] urls = new String[fURLImagesbyOffer.length()];
// looping through All Offers
for (int i = 0; i < fURLImagesbyOffer.length(); i++) {
JSONObject c = null;
c = fURLImagesbyOffer.getJSONObject(i);
urls[i] = c.getString(Constants.TAG_URL_IMAGE);
/**I use Glide to display the image in the ImageView**/
Glide.with(this).load(urls[0]).placeholder(R.drawable.splash_img).into(imgView);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
here it is the xml code:
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.xxxxxx.yyyy_ofer">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView4"
android:layout_marginTop="34dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginStart="20dp"
android:layout_toStartOf="@+id/textView5"
android:layout_toLeftOf="@+id/textView5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView5"
android:layout_alignParentRight="true"
android:layout_marginLeft="20dp"
android:layout_alignParentEnd="false"
android:layout_alignParentStart="false" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:layout_toEndOf="@+id/textView5"
android:layout_below="@+id/textView4"
android:adjustViewBounds="true" />
</RelativeLayout>
Please could you help me?
Thanks for advance,