-1

如何增加应用程序的内存?

E/GraphicsJNI(305): VM won't let us allocate 5529600 bytes

我有这个错误,我正在尝试应用

largeHeap="true"

但我收到一个错误:

error: No resource identifier found for attribute 'largeHeap' in package 'android'

我的代码:

public class FourthActivity extends Activity {
    ImageView fotik , cig, zajigalka, fotki, btn, string, flash, telefon;
    Animation textfade, buttonfade, fotikfade, sright, sdown, fl, stringfade, fotofade;

Timer t1, t2, t3, t4,t5;
public RelativeLayout lay;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.fourthlayout);

    ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this);
    lay = (RelativeLayout)this.findViewById(R.id.lay);
    lay.setOnTouchListener(activitySwipeDetector);

    fotik=(ImageView)findViewById(R.id.imageView1);
    fotki=(ImageView)findViewById(R.id.imageView2);
    flash=(ImageView)findViewById(R.id.imageView8);
    string=(ImageView)findViewById(R.id.imageView7);
    telefon=(ImageView)findViewById(R.id.imageView3);
    cig=(ImageView)findViewById(R.id.imageView4);
    zajigalka=(ImageView)findViewById(R.id.imageView6);     
    btn=(ImageView)findViewById(R.id.imageView5);           

    fotki.setVisibility(View.INVISIBLE);
    flash.setVisibility(View.INVISIBLE);
    string.setVisibility(View.INVISIBLE);
    btn.setVisibility(View.INVISIBLE);

    fotikfade=AnimationUtils.loadAnimation(this, R.anim.lay4translatefotik);
    fotofade=AnimationUtils.loadAnimation(this, R.anim.text_fadein_pop);
    fl=AnimationUtils.loadAnimation(this, R.anim.lay2scale);


     sright = AnimationUtils.loadAnimation(this, R.anim.lay2move_rotate_right);
     sdown = AnimationUtils.loadAnimation(this, R.anim.lay17translatepack);

     cig.startAnimation(sdown);
     zajigalka.startAnimation(sright);
     telefon.startAnimation(fotofade);
     fotik.setVisibility(View.INVISIBLE);


     fotik.startAnimation(fotikfade);
        fotik.setVisibility(View.VISIBLE);

        t2 = new Timer();
        t2.schedule(new TimerTask() {          
            @Override
            public void run() {
                TimerMethod2();} },  900);

}
protected void onStop(){
    super.onDestroy();      
    }

private void TimerMethod2()
{
    this.runOnUiThread(Timer_Tick2);
}
private Runnable Timer_Tick2 = new Runnable() {
    public void run() {

        t1 = new Timer();
        t1.schedule(new TimerTask() {          
            @Override
            public void run() {
                TimerMethod();} },  900);
        t5 = new Timer();
        t5.schedule(new TimerTask() {          
            @Override
            public void run() {
                TimerMethod5();} },  700);

    }
}; 

private void TimerMethod()
{
    this.runOnUiThread(Timer_Tick);
}
private Runnable Timer_Tick = new Runnable() {
    public void run() {

        fotki.setVisibility(View.VISIBLE);
         fotki.startAnimation(fotofade);
         string.setVisibility(View.VISIBLE);
         string.startAnimation(fotofade);
         btn.setVisibility(View.VISIBLE);
    }
}; 
private void TimerMethod5()
{
    this.runOnUiThread(Timer_Tick5);
}
private Runnable Timer_Tick5 = new Runnable() {
    public void run() {
         flash.startAnimation(fl);

    }
};
public void onClick(View v)
{
    Intent intent=new Intent(FourthActivity.this, FifthActivity.class);

      startActivity(intent);    
      onStop();

}
public class ActivitySwipeDetector implements View.OnTouchListener {

    static final String logTag = "ActivitySwipeDetector";
    private Activity activity;
    static final int MIN_DISTANCE = 100;
    private float downX, downY, upX, upY;

    public ActivitySwipeDetector(Activity activity){
        this.activity = activity;
    }

    public void onRightToLeftSwipe(){
        Intent intent=new Intent(FourthActivity.this, FifthActivity.class);
        startActivity(intent);
        onStop();
    }

    public void onLeftToRightSwipe()
    {
        Intent intent=new Intent(FourthActivity.this, ThirdActivity.class);
        startActivity(intent);
        onStop();
    }

    public boolean onTouch(View v, MotionEvent event) {
        switch(event.getAction()){
            case MotionEvent.ACTION_DOWN: {
                downX = event.getX();
                downY = event.getY();
                return true;
            }
            case MotionEvent.ACTION_UP: {
                upX = event.getX();
                upY = event.getY();

                float deltaX = downX - upX;
                float deltaY = downY - upY;

                if(Math.abs(deltaX) > MIN_DISTANCE){
                    if(deltaX < 0) { this.onLeftToRightSwipe(); return true; }
                    if(deltaX > 0) { this.onRightToLeftSwipe(); return true; }
                }
                else {
                        Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE);
                        return false; 
                }


                return true;
            }
        }
        return false;
    }

    }

}

4

2 回答 2

0

您是否已<application android:largeHeap="true" ...>在清单中定义为应用程序的属性?至少,您应该使用 Honeycomb 作为 ths 属性。

看看这个帖子:https ://stackoverflow.com/a/11275719/411951

于 2013-09-05T11:02:32.293 回答
0

在您的清单中将此代码写入应用程序标记中

<application android:icon="@drawable/icon" 
 android:label="@string/app_name" 
 android:largeHeap="true">

largeHeap 属性仅在 API 11 或更高版本之后出现

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

在您的清单中使用此代码将您的目标设置为 API 19

我希望这对你有帮助

于 2013-12-31T10:20:18.320 回答