0

I try to set a drawable into an ImageView. The source depends on the two digit day-num in month (stored in today). My API-Level is 17 (The Fairphone 1).

On the virtual devices I can see the picture. But when I install the app on my real phone, the ImageBox is there but empty (white).

This is the code where I set the Image:

ImageView image = (ImageView) findViewById(R.id.startImg);
String uri = "s_"+Integer.parseInt(today);
int imageResource = getBaseContext().getResources().getIdentifier(uri, "drawable", getPackageName());
image.setImageResource(imageResource);

This is my Layout-File:

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:textColor="@color/colorAccent"
        android:textSize="20dp"
        android:paddingBottom="16dp"
        android:id="@+id/textView"
        android:textAlignment="center"
        android:textStyle="bold"
        android:typeface="serif" />
    <ImageView
        android:contentDescription="Bild"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:id="@+id/startImg" />
    <GridView
        android:id="@+id/DatesGrid"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="3"
        >
    </GridView>
</LinearLayout>

The LogCat says nothing.

But I checked the App on a Phone on API-Level 22 (The Fairphone 2). Now the app crashes because of a wrong imageResource.

Question: Why can I see the picture in my Virtual Devices but not on my real device?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Micha
  • 1
  • 5

1 Answers1

0

Thanks to you all for your hints. I could solve the issue now.

There was a storage allocation error which was only debuggable on a different API-Level (22). The Level 17 has given no errors. I scaled the Images down now. This explains also why it works on the virtual devices with different storage-settings.

Micha
  • 1
  • 5