Android 无法加载活动。outofMemory运行时异常
我正在开发一个使用许多jpeg图像的应用程序。它总是发出outOfMemory错误异常。然后我试着解码它。但它仍然给出了错误。请帮我做这个。我不明白错误在哪里。 提前谢谢Android 无法加载活动。outofMemory运行时异常,android,out-of-memory,viewflipper,bitmapfactory,android-bitmap,Android,Out Of Memory,Viewflipper,Bitmapfactory,Android Bitmap,我正在开发一个使用许多jpeg图像的应用程序。它总是发出outOfMemory错误异常。然后我试着解码它。但它仍然给出了错误。请帮我做这个。我不明白错误在哪里。 提前谢谢 public class Kumana extends FragmentActivity implements LocationListener{ GoogleMap mGoogleMap; ArrayList<LatLng> mMarkerPoints; double mLatitude
public class Kumana extends FragmentActivity implements LocationListener{
GoogleMap mGoogleMap;
ArrayList<LatLng> mMarkerPoints;
double mLatitude = 0;
double mLongitude = 0;
Bitmap mCurrentBitmap=null;
BitmapFactory.Options mBitmapOptions;
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private ViewFlipper mViewFlipper,mViewFlipper2,mViewFlipper3;
private AnimationListener mAnimationListener;
ImageView iv1, iv2, iv3,iv4,iv5,iv6,iv7,iv8,iv9,iv10,iv11,iv12;
private Context mContext;
int mCurrentIndex=0;
@SuppressWarnings("deprecation")
private final GestureDetector detector = new GestureDetector(
new SwipeGestureDetector());
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.kumana);
final int[] imgIDs={R.drawable.blackneckedstork,R.drawable.eurasianspoonbill,R.drawable.greaterrackettaileddrongo,
R.drawable.kumana5,R.drawable.lesseradjunt,R.drawable.lesserwhistlingduck,R.drawable.malabartrogan,R.drawable.redfacedmalkoha,
R.drawable.sirkeermalkoha,R.drawable.thegreatthickknee,R.drawable.yellowfootedgreenpigeon};
iv1=(ImageView)findViewById(R.id.imgvw_kumana1);
iv2=(ImageView)findViewById(R.id.imgvw_kumana2);
iv3=(ImageView)findViewById(R.id.imgvw_kumana3);
iv4=(ImageView)findViewById(R.id.imgvw_kumana_breeding3);
iv5=(ImageView)findViewById(R.id.imgvw_kumana_breeding1);
iv6=(ImageView)findViewById(R.id.imgvw_kumana_breeding2);
iv7=(ImageView)findViewById(R.id.imgvw_kumana_breeding4);
iv8=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants1);
iv9=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants2);
iv10=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants3);
iv11=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants4);
iv12=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants5);
mBitmapOptions = new BitmapFactory.Options();
mBitmapOptions.inJustDecodeBounds=true;
BitmapFactory.decodeResource(getResources(), R.drawable.blackneckedstork);
mCurrentBitmap=Bitmap.createBitmap(mBitmapOptions.outWidth,mBitmapOptions.outHeight,Bitmap.Config.ARGB_8888);
mBitmapOptions.inJustDecodeBounds=false;
mBitmapOptions.inBitmap=mCurrentBitmap;
mBitmapOptions.inSampleSize=1;
BitmapFactory.decodeResource(getResources(), R.drawable.blackneckedstork);
iv1.setImageBitmap(mCurrentBitmap);
mCurrentIndex=(mCurrentIndex+1)%imgIDs.length;
BitmapFactory.Options bitmapOptions=null;
bitmapOptions=mBitmapOptions;
bitmapOptions.inBitmap=mCurrentBitmap;
mCurrentBitmap=BitmapFactory.decodeResource(getResources(), imgIDs[mCurrentIndex],bitmapOptions);
iv1.setImageBitmap(mCurrentBitmap);
mContext = this;
mViewFlipper = (ViewFlipper) this.findViewById(R.id.view_flipper_kumana1);
mViewFlipper2 = (ViewFlipper) this.findViewById(R.id.view_flipper_kumana2);
mViewFlipper3 = (ViewFlipper) this.findViewById(R.id.view_flipper_kumana3);
// sets auto flipping
mViewFlipper.setAutoStart(true);
mViewFlipper.setFlipInterval(8000);
mViewFlipper.startFlipping();
mViewFlipper2.setAutoStart(true);
mViewFlipper2.setFlipInterval(8000);
mViewFlipper2.startFlipping();
mViewFlipper3.setAutoStart(true);
mViewFlipper3.setFlipInterval(8000);
mViewFlipper3.startFlipping();
mViewFlipper.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
detector.onTouchEvent(event);
return true;
}
});
mViewFlipper2.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
detector.onTouchEvent(event);
return true;
}
});
mViewFlipper3.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
detector.onTouchEvent(event);
return true;
}
});
// animation listener
mAnimationListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// animation started event
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO animation stopped event
}
};
class SwipeGestureDetector extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
try {
// right to left swipe
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_in));
mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_out));
// controlling animation
mViewFlipper.getInAnimation().setAnimationListener(mAnimationListener);
mViewFlipper.showNext();
mViewFlipper2.setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_in));
mViewFlipper2.setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_out));
// controlling animation
mViewFlipper2.getInAnimation().setAnimationListener(mAnimationListener);
mViewFlipper2.showNext();
mViewFlipper3.setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_in));
mViewFlipper3.setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_out));
// controlling animation
mViewFlipper3.getInAnimation().setAnimationListener(mAnimationListener);
mViewFlipper3.showNext();
return true;
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_in));
mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_out));
// controlling animation
mViewFlipper.getInAnimation().setAnimationListener(mAnimationListener);
mViewFlipper.showPrevious();
mViewFlipper2.setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_in));
mViewFlipper2.setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_out));
// controlling animation
mViewFlipper2.getInAnimation().setAnimationListener(mAnimationListener);
mViewFlipper2.showPrevious();
mViewFlipper3.setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_in));
mViewFlipper3.setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.right_out));
// controlling animation
mViewFlipper3.getInAnimation().setAnimationListener(mAnimationListener);
mViewFlipper3.showPrevious();
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
//Google Map methods
}
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ViewFlipper
android:id="@+id/view_flipper_kumana1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumana1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/kumana8" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaLbl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumana2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/kumana5" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaLbl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumana3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/lesserwhistlingduck" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaLbl" />
</RelativeLayout>
</ViewFlipper>
<ImageView
android:id="@+id/swipe_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="@string/imageVw"
android:src="@drawable/right_arrow" />
<ImageView
android:id="@+id/swipe_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="@string/imageVw"
android:src="@drawable/right_arrow2" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ViewFlipper
android:id="@+id/view_flipper_kumana2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumana_breeding3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/eurasianspoonbill" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc4_bird3" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumana_breeding1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/blackneckedstork" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc4_bird1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumana_breeding2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/lesseradjunt" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc4_bird2" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumana_breeding4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/thegreatthickknee" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc4_bird4" />
</RelativeLayout>
</ViewFlipper>
<ImageView
android:id="@+id/swipe_left1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="@string/imageVw"
android:src="@drawable/arrowleft" />
<ImageView
android:id="@+id/swipe_right1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="@string/imageVw"
android:src="@drawable/arrowright" />
</RelativeLayout>
<TextView
android:id="@+id/kumanaDesc5_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:paddingTop="10dp"
android:text="@string/kumanaDesc5_header"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/kirinddescripion3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:paddingTop="10dp"
android:text="@string/kumanaDesc6_RareMigrants"
android:textSize="15sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ViewFlipper
android:id="@+id/view_flipper_kumana3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumanaDesc6_RareMigrants1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/yellowfootedgreenpigeon" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc6_RareMigrants1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumanaDesc6_RareMigrants2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/greaterrackettaileddrongo" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc6_RareMigrants2_graterRacket" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumanaDesc6_RareMigrants3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/malabartrogan" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc6_RareMigrants3" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumanaDesc6_RareMigrants4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/redfacedmalkoha" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc6_RareMigrants4" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imgvw_kumanaDesc6_RareMigrants5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="@string/imageVw"
android:scaleType="centerCrop"
android:src="@drawable/sirkeermalkoha" />
<TextView
style="@style/ImageTitle"
android:text="@string/kumanaDesc6_RareMigrants4" />
</RelativeLayout>
</ViewFlipper>
<ImageView
android:id="@+id/swipe_left1_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="@string/imageVw"
android:src="@drawable/arrowleft" />
<ImageView
android:id="@+id/swipe_right1_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="@string/imageVw"
android:src="@drawable/arrowright" />
</RelativeLayout>
<fragment
android:id="@+id/map_kumana"
android:layout_width="match_parent"
android:layout_height="466dp"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
</ScrollView>
公共类Kumana扩展FragmentActivity实现LocationListener{
谷歌地图;
ArrayList mMarkerPoints;
双梯度=0;
双倍长度=0;
位图mCurrentBitmap=null;
BitmapFactory.Options-mBitmapOptions;
专用静态最终整数滑动距离=120;
专用静态最终整数滑动\u阈值\u速度=200;
私有视图翻转器mViewFlipper、mViewFlipper2、mViewFlipper3;
私人动画监听器mAnimationListener;
图像视图iv1、iv2、iv3、iv4、iv5、iv6、iv7、iv8、iv9、iv10、iv11、iv12;
私有上下文;
int mCurrentIndex=0;
@抑制警告(“弃用”)
私人最终手势检测器=新手势检测器(
新SwipeGestureDetector());
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(右布局图,kumana);
final int[]imgIDs={R.drawable.blackneckedstork,R.drawable.eurasianspoonbill,R.drawable.greaterrackttaileddrongo,
拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,拉丝,
R.drawable.sirkeermalkoha,R.drawable.Thegreathickknee,R.drawable.YellowFootedgreen鸽子};
iv1=(ImageView)findViewById(R.id.imgvw_kumana1);
iv2=(ImageView)findViewById(R.id.imgvw_kumana2);
iv3=(ImageView)findViewById(R.id.imgvw_kumana3);
iv4=(图像视图)findViewById(R.id.imgvw_kumana_繁殖3);
iv5=(图像视图)findViewById(R.id.imgvw_kumana_breeding1);
iv6=(图像视图)findViewById(R.id.imgvw_kumana_breeding2);
iv7=(图像视图)findViewById(R.id.imgvw_kumana_繁育4);
iv8=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants1);
iv9=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants2);
iv10=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants3);
iv11=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants4);
iv12=(ImageView)findViewById(R.id.imgvw_kumanaDesc6_RareMigrants5);
mBitmapOptions=新的BitmapFactory.Options();
mBitmapOptions.inJustDecodeBounds=true;
decodeResource(getResources(),R.drawable.blackneckedstork);
mCurrentBitmap=Bitmap.createBitmap(mBitmapOptions.outWidth、mBitmapOptions.outHeight、Bitmap.Config.argb8888);
mBitmapOptions.inJustDecodeBounds=false;
mbitMap=mCurrentBitmap;
MbitPoputions.inSampleSize=1;
decodeResource(getResources(),R.drawable.blackneckedstork);
iv1.设置图像位图(mCurrentBitmap);
mCurrentIndex=(mCurrentIndex+1)%imgIDs.length;
选项bitmapOptions=null;
bitmapOptions=MbitPoputions;
inBitmap=mCurrentBitmap;
mCurrentBitmap=BitmapFactory.decodeResource(getResources(),imgIDs[mCurrentIndex],bitmapOptions);
iv1.设置图像位图(mCurrentBitmap);
mContext=这个;
mViewFlipper=(ViewFlipper)this.findViewById(R.id.view\u flipper\u kumana1);
mViewFlipper2=(ViewFlipper)this.findViewById(R.id.view\u flipper\u kumana2);
mViewFlipper3=(ViewFlipper)this.findViewById(R.id.view\u flipper\u kumana3);
//设置自动翻转
mViewFlipper.setAutoStart(true);
mViewFlipper.setFlipInterval(8000);
mViewFlipper.startFlipping();
mViewFlipper2.setAutoStart(true);
mViewFlipper2.setFlipInterval(8000);
mViewFlipper2.startFlipping();
mViewFlipper3.setAutoStart(true);
mViewFlipper3.setFlipInterval(8000);
mViewFlipper3.startFlipping();
mViewFlipper.setOnTouchListener(新的OnTouchListener(){
@凌驾
公共布尔onTouch(最终视图、最终运动事件){
探测器。开孔(事件);
返回true;
}
});
mViewFlipper2.setOnTouchListener(新的OnTouchListener(){
@凌驾
公共布尔onTouch(最终视图、最终运动事件){
探测器。开孔(事件);
返回true;
}
});
mViewFlipper3.setOnTouchListener(新的OnTouchListener(){
@凌驾
公共布尔onTouch(最终视图、最终运动事件){
探测器。开孔(事件);
返回true;
}
});
//动画监听器
mAnimationListener=新建动画。AnimationListener(){
@凌驾
onAnimationStart上的公共无效(动画){
//动画启动事件
}
@凌驾
onAnimationRepeat上的公共无效(动画){
}
@凌驾
onAnimationEnd上的公共无效(动画){
//TODO动画停止事件
}
};
类SwipeGestureDetector扩展了SimpleOnGestureListener{
@凌驾
公共布尔onFling(运动事件e1、运动事件e2、浮点速度X、,
浮动速度y){
试一试{
//从右向左滑动
如果(e1.getX()-e2.getX()>滑动最小距离
&&Math.abs(velocityX)>滑动阈值(速度){
mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext,R.anim.left_in));
mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext,R.anim.left_out));
//控制动画
mViewFlipper.getInAnimatio
android:largeHeapSize="true"
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(filePath);
int srcWidth = o.outWidth;
int srcHeight = o.outHeight;
int dstWidth = 1920;
int dstHeight = 1080;
int inSampleSize = 1;
if (srcHeight > dstHeight || srcWidth > dstWidth) {
final int halfHeight = srcHeight / 2;
final int halfWidth = srcWidth / 2;
while ((halfHeight / inSampleSize) > dstWidth
&& (halfWidth / inSampleSize) > dstWidth) {
inSampleSize *= 2;
}
}
o.inSampleSize = inSampleSize;
o.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(filePath, o);