使用时,意图活动停止unexpactedly [英] activity stops unexpactedly when using Intent
本文介绍了使用时,意图活动停止unexpactedly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好stackoverflowers我新到蜜蜂到Android。可以任何一个帮助我的后面,从致命的错误出走。
05-14 19:32:49.552:E / AndroidRuntime(1657):致命异常:主要
05-14 19:32:49.552:E / AndroidRuntime(1657):了java.lang.RuntimeException:无法启动活动ComponentInfo {com.DJ.HOLYHERB / com.DJ.HOLYHERB.Prd_list}:android.view.InflateException:二进制XML文件行#2:错误充气类<&不明GT;
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.ActivityThread.access $ 1500(ActivityThread.java:117)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:928)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.os.Handler.dispatchMessage(Handler.java:99)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.os.Looper.loop(Looper.java:123)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.ActivityThread.main(ActivityThread.java:3647)
05-14 19:32:49.552:E / AndroidRuntime(1657):在java.lang.reflect.Method.invokeNative(本机方法)
05-14 19:32:49.552:E / AndroidRuntime(1657):在java.lang.reflect.Method.invoke(Method.java:507)
05-14 19:32:49.552:E / AndroidRuntime(1657):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
05-14 19:32:49.552:E / AndroidRuntime(1657):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-14 19:32:49.552:E / AndroidRuntime(1657):在dalvik.system.NativeStart.main(本机方法)
05-14 19:32:49.552:E / AndroidRuntime(1657):android.view.InflateException:二进制XML文件行#2:造成错误充气类<&不明GT;
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.LayoutInflater.createView(LayoutInflater.java:518)
05-14 19:32:49.552:E / AndroidRuntime(1657):在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.LayoutInflater.inflate(LayoutInflater.java:386)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-14 19:32:49.552:E / AndroidRuntime(1657):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.Activity.setContentView(Activity.java:1657)
05-14 19:32:49.552:E / AndroidRuntime(1657):在com.xyz.My_list.onCreate(My_list.java:429)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
05-14 19:32:49.552:E / AndroidRuntime(1657):11 ...更多
05-14 19:32:49.552:E / AndroidRuntime(1657):因:java.lang.reflect.InvocationTargetException
05-14 19:32:49.552:E / AndroidRuntime(1657):在java.lang.reflect.Constructor.constructNative(本机方法)
05-14 19:32:49.552:E / AndroidRuntime(1657):在java.lang.reflect.Constructor.newInstance(Constructor.java:415)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.LayoutInflater.createView(LayoutInflater.java:505)
05-14 19:32:49.552:E / AndroidRuntime(1657):21 ...更多
05-14 19:32:49.552:E / AndroidRuntime(1657):java.lang.OutOfMemoryError:产生的原因位图大小超过VM预算
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.Bitmap.nativeCreate(本机方法)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.Bitmap.createBitmap(Bitmap.java:477)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.Bitmap.createBitmap(Bitmap.java:444)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.BitmapFactory.finishDe code(BitmapFactory.java:488)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.BitmapFactory.de codeStream(BitmapFactory.java:463)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.BitmapFactory.de codeResourceStream(BitmapFactory.java:326)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.content.res.Resources.loadDrawable(Resources.java:1709)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.View<&初始化GT;(View.java:1951)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.View<&初始化GT;(View.java:1899)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.view.ViewGroup<&初始化GT;(ViewGroup.java:286)
05-14 19:32:49.552:E / AndroidRuntime(1657):在android.widget.LinearLayout<&初始化GT;(LinearLayout.java:120)
05-14 19:32:49.552:E / AndroidRuntime(1657):24 ...更多
05-14 19:32:52.442:I /流程(1657年):发送信号。 PID:1657 SIG:9
和从那里exeption被抛出作为showned跟着::它的一个登录表单
包com.xyz.ACCOUNT;进口的java.util.ArrayList;
进口java.util.concurrent.ExecutionException;进口org.apache.http.NameValuePair;
进口org.apache.http.message.BasicNameValuePair;
进口org.json.JSONArray;
进口org.json.JSONObject;进口android.app.Activity;
进口android.app.AlertDialog;
进口android.app.Dialog;
进口android.app.ProgressDialog;
进口android.content.Context;
进口android.content.DialogInterface;
进口android.content.Intent;
进口android.content.res.Resources;
进口android.os.AsyncTask;
进口android.os.Bundle;
进口android.util.Log;
进口android.view.View;
进口android.widget.EditText;
进口android.widget.TextView;
进口android.widget.Toast;进口com.xyz.My_list;
进口com.xyz.R;公共类SignInActivity延伸活动{ 电子邮件的EditText,PWD;
TextView的err_tv;
我的意图;
上下文℃;
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.signin);
C = getApplicationContext();
电子邮件=(EditText上)findViewById(R.id.email);
PWD =(EditText上)findViewById(R.id.pwd);
err_tv =(的TextView)findViewById(R.id.info_text);
}
公共无效goto_signUp(视图v){
I =新意图(这一点,SignUpActivity.class);
startActivity(ⅰ);
}
公共无效goto_forgotPwd(视图v){
I =新意图(这一点,ForgotPwdActivity.class);
startActivity(ⅰ);
}
公共无效action_signIn(视图v){
尝试{
登入L =新登入(本);
l.execute(。email.getText()的toString(),pwd.getText()的toString());
}赶上(例外五){
味精=错误 - + e.getLocalizedMessage();
的ShowDialog(DIALOG_ERR_MESSAGE);
}
} 一流的登入扩展的AsyncTask<弦乐,太虚,布尔> {
//字符串消息;
ProgressDialog mProgressDialog;
布尔isSuccess; 私人活动活动; 公共登入(活动活动){
this.activity =活动;
} 资源解析度= getResources();
字符串httpConnStr = res.getString(R.string.httpConnStr); 在preExecute()保护无效{mProgressDialog =
ProgressDialog.show(SignInActivity.this,请稍候...
认证...); } @覆盖
保护无效onPostExecute(布尔结果){
// TODO自动生成方法存根
super.onPostExecute(结果);
mProgressDialog.cancel();
如果(结果){
// Toast.makeText(SignInActivity.this,欢迎::+ +的user_id::+ user_fname,
// Toast.LENGTH_LONG).show();
//味精=欢迎 - + USER_ID +::+ user_fname;
//的ShowDialog(DIALOG_ERR_MESSAGE);
Toast.makeText(活动,Boolean.toString(结果),Toast.LENGTH_LONG).show();
activity.startActivity(新意图(活动,My_list.class));
}其他{
err_tv.setText(无效EMAILID /密码);
味精=无效EMAILID /密码;
的ShowDialog(DIALOG_ERR_MESSAGE);
}
}
@覆盖
保护布尔doInBackground(字符串... PARAMS){
// TODO自动生成方法存根
字符串email =参数[0];
串PWD =参数[1];
返回isSuccess = getServerData(httpConnStr,电子邮件,PWD);
}
}
串USER_ID =0,user_fname =#;
私人布尔getServerData(字符串CONN_KEY,电子邮件字符串,字符串PWD){
ArrayList的<&的NameValuePair GT; postParameters =新的ArrayList<&的NameValuePair GT;();
postParameters.add(新BasicNameValuePair(查询,签到));
postParameters.add(新BasicNameValuePair(电子邮件,电子邮件));
postParameters.add(新BasicNameValuePair(PWD,PWD));
串响应=无效;
尝试{
响应= com.DJ.HOLYHERB.CONN.CustomHttpClient.executeHttpPost(
CONN_KEY,postParameters);
字符串结果= response.toString();
如果(result.equals()){
返回false;
}其他{
尝试{
JSONArray jArray =新JSONArray(结果);
的JSONObject json_data = jArray.getJSONObject(0); USER_ID = json_data.getString(user_ID的);
user_fname = json_data.getString(user_fname); }赶上(例外五){
Log.e(log_tag,错误分析数据+ e.toString());
味精=错误分析数据+ e.toString();
的ShowDialog(DIALOG_ERR_MESSAGE);
返回false;
}
}
}赶上(例外五){
Log.e(log_tag,在HTTP连接错误!+ e.toString()); 味精=错误http连接!! + e.toString();
味精=错误连接\\ n是否检查乌尔连接和放大器;再试;
的ShowDialog(DIALOG_ERR_MESSAGE);
返回false;
}
返回true;
}
私有静态最终诠释DIALOG_ERR_MESSAGE = 1;
私有静态最终诠释DIALOG_PROGRESS = 4;
私有静态最终诠释MAX_PROGRESS = 100;
私人ProgressDialog mProgressDialog;
弦乐味精= - ,标题=错误......; @覆盖
保护对话框onCreateDialog(INT ID){
开关(ID){
案例DIALOG_ERR_MESSAGE:
返回新AlertDialog.Builder(本)
.setIcon(R.drawable.alert_dialog_icon)
.setTitle(职称)
.setMessage(MSG)
.setNegativeButton(取消,
新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话框,
INT whichButton){ //用户点击取消如此做一些东西
}
})。创建();
案例DIALOG_PROGRESS:
mProgressDialog =新ProgressDialog(本);
mProgressDialog.setIcon(R.drawable.alert_dialog_icon);
mProgressDialog.setTitle(职称);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setMax(MAX_PROGRESS);
mProgressDialog.setButton(隐藏,
新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话框,
INT whichButton){
}
});
mProgressDialog.setButton2(取消,
新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话框,
INT whichButton){
}
});
返回mProgressDialog;
}
返回null;
}
}
解决方案
产生的原因:java.lang.OutOfMemoryError:位图大小超过VM预算
尝试回收您正在使用和位图的设置为null ,使用 bitmap.recycle()
您也可以秤/调整您的位图,以确保它使用最小可能的空间。
hello stackoverflowers i m new bee to the android. could any one help me out to run away from FATAL Error as followed.
05-14 19:32:49.552: E/AndroidRuntime(1657): FATAL EXCEPTION: main
05-14 19:32:49.552: E/AndroidRuntime(1657): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.DJ.HOLYHERB/com.DJ.HOLYHERB.Prd_list}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.os.Looper.loop(Looper.java:123)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.ActivityThread.main(ActivityThread.java:3647)
05-14 19:32:49.552: E/AndroidRuntime(1657): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 19:32:49.552: E/AndroidRuntime(1657): at java.lang.reflect.Method.invoke(Method.java:507)
05-14 19:32:49.552: E/AndroidRuntime(1657): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-14 19:32:49.552: E/AndroidRuntime(1657): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-14 19:32:49.552: E/AndroidRuntime(1657): at dalvik.system.NativeStart.main(Native Method)
05-14 19:32:49.552: E/AndroidRuntime(1657): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
05-14 19:32:49.552: E/AndroidRuntime(1657): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-14 19:32:49.552: E/AndroidRuntime(1657): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.Activity.setContentView(Activity.java:1657)
05-14 19:32:49.552: E/AndroidRuntime(1657): at com.xyz.My_list.onCreate(My_list.java:429)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
05-14 19:32:49.552: E/AndroidRuntime(1657): ... 11 more
05-14 19:32:49.552: E/AndroidRuntime(1657): Caused by: java.lang.reflect.InvocationTargetException
05-14 19:32:49.552: E/AndroidRuntime(1657): at java.lang.reflect.Constructor.constructNative(Native Method)
05-14 19:32:49.552: E/AndroidRuntime(1657): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
05-14 19:32:49.552: E/AndroidRuntime(1657): ... 21 more
05-14 19:32:49.552: E/AndroidRuntime(1657): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.Bitmap.nativeCreate(Native Method)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:463)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:326)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.content.res.Resources.loadDrawable(Resources.java:1709)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.View.<init>(View.java:1951)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.View.<init>(View.java:1899)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.view.ViewGroup.<init>(ViewGroup.java:286)
05-14 19:32:49.552: E/AndroidRuntime(1657): at android.widget.LinearLayout.<init>(LinearLayout.java:120)
05-14 19:32:49.552: E/AndroidRuntime(1657): ... 24 more
05-14 19:32:52.442: I/Process(1657): Sending signal. PID: 1657 SIG: 9
and its a "sign in form" from where exeption is get thrown is as showned followed::
package com.xyz.ACCOUNT;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.xyz.My_list;
import com.xyz.R;
public class SignInActivity extends Activity {
EditText email,pwd;
TextView err_tv;
Intent i;
Context c;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.signin);
c=getApplicationContext();
email=(EditText)findViewById(R.id.email);
pwd=(EditText)findViewById(R.id.pwd);
err_tv=(TextView)findViewById(R.id.info_text);
}
public void goto_signUp(View v){
i=new Intent(this,SignUpActivity.class);
startActivity(i);
}
public void goto_forgotPwd(View v){
i=new Intent(this,ForgotPwdActivity.class);
startActivity(i);
}
public void action_signIn(View v){
try{
signin l=new signin(this);
l.execute(email.getText().toString(), pwd.getText().toString());
}catch (Exception e) {
msg = "Err-"+e.getLocalizedMessage();
showDialog(DIALOG_ERR_MESSAGE);
}
}
class signin extends AsyncTask<String, Void, Boolean> {
// String message;
ProgressDialog mProgressDialog;
boolean isSuccess;
private Activity activity;
public signin(Activity activity) {
this.activity = activity;
}
Resources res = getResources();
String httpConnStr = res.getString(R.string.httpConnStr);
protected void onPreExecute() { mProgressDialog =
ProgressDialog.show(SignInActivity.this, "Please wait...",
"Authenticating..."); }
@Override
protected void onPostExecute(Boolean result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
mProgressDialog.cancel();
if(result){
// Toast.makeText(SignInActivity.this, "Welcome :: "+user_id+"::"+user_fname,
// Toast.LENGTH_LONG).show();
// msg = "Welcome - "+user_id+"::"+user_fname;
// showDialog(DIALOG_ERR_MESSAGE);
Toast.makeText(activity, Boolean.toString(result), Toast.LENGTH_LONG).show();
activity.startActivity(new Intent(activity, My_list.class));
}else{
err_tv.setText("Invalid EmailId/Password");
msg = "Invalid EmailId/Password";
showDialog(DIALOG_ERR_MESSAGE);
}
}
@Override
protected Boolean doInBackground(String... params) {
// TODO Auto-generated method stub
String email = params[0];
String pwd = params[1];
return isSuccess = getServerData(httpConnStr,email,pwd);
}
}
String user_id="0",user_fname="#";
private boolean getServerData(String CONN_KEY,String email, String pwd) {
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("query", "signIn"));
postParameters.add(new BasicNameValuePair("email", email));
postParameters.add(new BasicNameValuePair("pwd", pwd));
String response = null;
try {
response = com.DJ.HOLYHERB.CONN.CustomHttpClient.executeHttpPost(
CONN_KEY, postParameters);
String result = response.toString();
if(result.equals("")){
return false;
}else{
try {
JSONArray jArray = new JSONArray(result);
JSONObject json_data = jArray.getJSONObject(0);
user_id = json_data.getString("user_id");
user_fname = json_data.getString("user_fname");
} catch (Exception e) {
Log.e("log_tag", "Error parsing data " + e.toString());
msg = "Error parsing data " + e.toString();
showDialog(DIALOG_ERR_MESSAGE);
return false;
}
}
} catch (Exception e) {
Log.e("log_tag", "Error in http connection!!" + e.toString());
msg = "Error in http connection!!" + e.toString();
msg = "Error in Connection.\nDo check ur connection & try Again.";
showDialog(DIALOG_ERR_MESSAGE);
return false;
}
return true;
}
private static final int DIALOG_ERR_MESSAGE = 1;
private static final int DIALOG_PROGRESS = 4;
private static final int MAX_PROGRESS = 100;
private ProgressDialog mProgressDialog;
String msg = "-", title = "ERROR...";
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_ERR_MESSAGE:
return new AlertDialog.Builder(this)
.setIcon(R.drawable.alert_dialog_icon)
.setTitle(title)
.setMessage(msg)
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
// User clicked Cancel so do some stuff
}
}).create();
case DIALOG_PROGRESS:
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setIcon(R.drawable.alert_dialog_icon);
mProgressDialog.setTitle(title);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setMax(MAX_PROGRESS);
mProgressDialog.setButton("hide",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
mProgressDialog.setButton2("cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
return mProgressDialog;
}
return null;
}
}
解决方案
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
Try to recycle the bitmaps that you are using and set them to null, by using bitmap.recycle()
.
You could also scale/resize your bitmap to make sure that it uses the minimum possible space.
这篇关于使用时,意图活动停止unexpactedly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文