运行我的应用程序后,我遇到了这个错误。
在此之前有一条错误消息:
"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;
}
}
}
}
}
请如何解决错误消息。