Bonjour,
Dans mon appli, j'ai une imageview dans laquelle j'affiche les images provenant d'un serveur distant.
Lorsque, je lance mon appli en mode debug sur ma tablette (android 4.0), les images s'affichent bien.
Mais lorsque, je le fais depuis mes téléphones (android 5, android 6), aucune image ne s'affiche et je n'ai même pas de message d'erreur dans les logs.
Le code java est le suivant:
celui de la page contenant l'imageview est la suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 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(); } } }
Merci d'avance pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 <?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>
Partager