App Is Crashing Only On Samsung Devices
I basically have a splash screen with the follywing code...I noticed that when I run it in most android devices,it works but only in samsung devices(not dependent on screen size,I
Solution 1:
Update:
your referencing to ImageView
before you create it, so I've just rearrange UI items, and if you have declared an id for a view, for ex android:id="@+id/imageView"
you should remove +
item on next refrence, so use android:layout_below="@id/imageView"
isntade if android:layout_below="@+id/imageView"
Check this out
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/white"><ImageViewandroid:id="@+id/imageView"android:layout_width="170dp"android:layout_height="200dp"android:layout_alignParentTop="true"android:layout_centerHorizontal="true"android:layout_marginTop="50dp"android:background="@drawable/images" /><TextViewandroid:id="@+id/textView13"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/imageView"android:layout_centerHorizontal="true"android:layout_marginTop="48dp"android:text="@string/app_name"android:textColor="@color/colorPrimaryDark"android:textSize="50sp"android:textStyle="bold" /><TextViewandroid:id="@+id/textView14"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/textView13"android:layout_centerHorizontal="true"android:text="Powered by BS " /></RelativeLayout>
Solution 2:
The crash can only be due to the image that you are currently using. There must be some odd dimensions. To solve this you can either use a different image or you can use a image caching library Glide
A sample code for using Glide is
Displaydisplay= getWindowManager().getDefaultDisplay();
intheight= display.getHeight();
intwidth= display.getWidth();
finalRelativeLayoutlayout= (RelativeLayout) findViewById(R.id.searchCityGuide);
Glide.with(this).load(R.drawable.exploref).asBitmap().into(newSimpleTarget<Bitmap>((int) width, (int) height) {
@OverridepublicvoidonResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
Drawabledrawable=newBitmapDrawable(resource);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
layout.setBackground(drawable);
}
}
});
Post a Comment for "App Is Crashing Only On Samsung Devices"