-1

アプリを実行した後、このエラーが発生しました。

そしてその前にエラーメッセージがあります:

"Out of memory on a 30720016-byte allocation."

私の画像はすべてdrawableフォルダ内にあります。

ここに私のコードがあります:

package com.androidteam.sg.easy.taxi.booking;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Declare our View variables and assign them the Views from the layout file
    Button getAnswerButton = (Button) findViewById(R.id.button1);
    Button getAnswerButton1 = (Button) findViewById(R.id.button2);
    Button getAnswerButton2 = (Button) findViewById(R.id.button3);
    Button getAnswerButton3 = (Button) findViewById(R.id.button4);
    Button getAnswerButton4 = (Button) findViewById(R.id.button5);
    Button getAnswerButton5 = (Button) findViewById(R.id.button6);
    Button getAnswerButton6 = (Button) findViewById(R.id.button7);
    Button getAnswerButton7 = (Button) findViewById(R.id.button8);

    //Add PhoneStateListener
    PhoneCallListener phoneListener = new PhoneCallListener();
    TelephonyManager telephonyManager = (TelephonyManager) this
            .getSystemService(Context.TELEPHONY_SERVICE);
    telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);

    getAnswerButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer by calling the number
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:65521111"));
            startActivity(intent);
        }
    });
    getAnswerButton1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer label with answer
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:65521111"));
            startActivity(intent);
        }
    });
    getAnswerButton2.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer label with answer
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:6778 0808"));
            startActivity(intent);
        }
    });
    getAnswerButton3.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer label with answer
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:6363 0808"));
            startActivity(intent);
        }
    });
    getAnswerButton4.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer label with answer
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:6485 7777"));
            startActivity(intent);
        }
    });
    getAnswerButton5.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer label with answer
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:6555 8888"));
            startActivity(intent);
        }
    });
    getAnswerButton6.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer label with answer
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:6555 3333"));
            startActivity(intent);
        }
    });
    getAnswerButton7.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            //The button was clicked, so update the answer label with answer
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse("tel:6293 5545"));
            startActivity(intent);
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}



//monitor phone call activities

private class PhoneCallListener extends PhoneStateListener {

    private boolean isPhoneCalling = false;

    String LOG_TAG = "LOGGING 123";

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {

        if (TelephonyManager.CALL_STATE_RINGING == state) {
            // phone ringing
            Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
        }

        if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
            // active
            Log.i(LOG_TAG, "OFFHOOK");

            isPhoneCalling = true;
        }

        if (TelephonyManager.CALL_STATE_IDLE == state) {
            // run when class initial and phone call ended, 
            // need detect flag from CALL_STATE_OFFHOOK
            Log.i(LOG_TAG, "IDLE");

            if (isPhoneCalling) {

                Log.i(LOG_TAG, "restart app");

                // restart app
                Intent i = getBaseContext().getPackageManager()
                    .getLaunchIntentForPackage(
                        getBaseContext().getPackageName());
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(i);

                isPhoneCalling = false;
            }

        }
    }
}


}

エラーメッセージの解決方法を教えてください。

4

1 に答える 1

1

これは、イメージのサイズが大きすぎてアプリケーションのヒープに収まらない場合に発生します。Android アプリのヒープは、Android 4.2 から 16MB です。おそらく、イメージが大きすぎてヒープ メモリに収まらず、メモリ不足エラーが発生しています。しかし、コードからは、コード内で画像を使用しているようには見えません。したがって、アプリで高品質の画像を表示しようとしている場合は、フォルダー
drawable-hdpi 、 drawable-ldpi 、 drawable-xhdpi 、 drawable-mdpi に低解像度のデバイス用の画像も用意してください。

于 2013-10-20T06:27:17.263 に答える