Android中显示的logcat只需关闭虚拟机? [英] The logcat in android shows simply shutting down the VM?

查看:183
本文介绍了Android中显示的logcat只需关闭虚拟机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天它的工作很好, 但今天显示消息 不幸的是,应用程序已经停止, 和logcat中显示关闭虚拟机。

Yesterday it worked perfectly, but today shows a message "unfortunately the app has stopped", and the logcat shows "shutting down the VM".

这个应用程序的堆栈跟踪。

Stack Trace of this app..

11-27 13:24:17.035: W/Trace(806): Unexpected value from nativeGetEnabledTags: 0
11-27 13:24:17.455: W/Trace(806): Unexpected value from nativeGetEnabledTags: 0
11-27 13:24:17.485: W/Trace(806): Unexpected value from nativeGetEnabledTags: 0
11-27 13:24:17.485: D/AndroidRuntime(806): Shutting down VM
11-27 12:30:51.683: D/AndroidRuntime(734): Shutting down VM
11-27 12:30:51.943: D/dalvikvm(734): GC_CONCURRENT freed 137K, 9% free 2625K/2880K,paused23ms+7ms, total 230ms
11-27 12:37:12.259: D/dalvikvm(878): newInstance failed: p0 i0 [0 a1
11-27 12:37:12.259: D/AndroidRuntime(878): Shutting down VM
11-27 12:43:22.839: D/dalvikvm(939): newInstance failed: p0 i0 [0 a1
11-27 12:43:22.878: D/AndroidRuntime(939): Shutting down VM

这是程序。

package com.raghuram.simplecalculator;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;

public abstract class CalculatorActivity extends Activity 
{

    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculator);
        OnClickListener addlisten= new OnClickListener()
        {
            public void onClick(View v) 
                {
                    EditText tx1=(EditText) findViewById(R.id.editText1);
                    EditText tx2=(EditText) findViewById(R.id.editText2);
                    EditText tx3=(EditText) findViewById(R.id.editText3);
                    Float res=Float.parseFloat(tx1.getText().toString()) + Float.parseFloat(tx2.getText().toString());                  
                    tx3.setText(Float.toString(res));


                }
        };

        ImageButton a=(ImageButton) findViewById(R.id.imageButton1);
        a.setOnClickListener(addlisten);

        OnClickListener sublisten= new OnClickListener()
        {
            public void onClick(View v) 
                {
                    EditText tx1=(EditText) findViewById(R.id.editText1);
                    EditText tx2=(EditText) findViewById(R.id.editText2);
                    EditText tx3=(EditText) findViewById(R.id.editText3);                   
                    Float res1=Float.parseFloat(tx1.getText().toString()) - Float.parseFloat(tx2.getText().toString());                 
                    tx3.setText(Float.toString(res1));

                }
        };

        ImageButton s=(ImageButton) findViewById(R.id.imageButton2);
        s.setOnClickListener(sublisten);

        OnClickListener mullisten= new OnClickListener()
        {
            public void onClick(View v) 
                {
                    EditText tx1=(EditText) findViewById(R.id.editText1);
                    EditText tx2=(EditText) findViewById(R.id.editText2);
                    EditText tx3=(EditText) findViewById(R.id.editText3);                   
                    Float res1=Float.parseFloat(tx1.getText().toString()) * Float.parseFloat(tx2.getText().toString());                 
                    tx3.setText(Float.toString(res1));

                }
        };

        ImageButton m=(ImageButton) findViewById(R.id.imageButton3);
        m.setOnClickListener(mullisten);

        OnClickListener divlisten= new OnClickListener()
        {
            public void onClick(View v) 
                {
                    EditText tx1=(EditText) findViewById(R.id.editText1);
                    EditText tx2=(EditText) findViewById(R.id.editText2);
                    EditText tx3=(EditText) findViewById(R.id.editText3);
                    Float x=Float.parseFloat(tx2.getText().toString());

                        if(x>0)
                        {
                            Float res1=Float.parseFloat(tx1.getText().toString()) / Float.parseFloat(tx2.getText().toString());                 
                            tx3.setText(Float.toString(res1));
                        }
                        else
                        {

                            Context context = getApplicationContext();
                            CharSequence text = "Invalid number.";
                            int duration = Toast.LENGTH_SHORT;

                            Toast toast = Toast.makeText(context, text, duration);
                            toast.show();

                        }

                }




        };

        ImageButton d=(ImageButton) findViewById(R.id.imageButton4);
        d.setOnClickListener(divlisten);


        ImageButton e=(ImageButton) findViewById(R.id.imageButton5);        
        e.setOnClickListener(new OnClickListener()
        {

            @Override
            public void onClick(View v) 
            {

                System.exit(0);
            }

        });

    }





    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_calculator, menu);
        return true;
    }

}

它显示了确切的结果昨天,但现在收forcely .. 如何管理内存。

It shows the exact results yesterday, but now it closed forcely.. how to manage the memory.

推荐答案

在你的类名称中删除摘要

和真实致电停止你的活动完成()而不是 System.exit(0)

And true to stop your activity by calling finish() instead of System.exit(0).

这篇关于Android中显示的logcat只需关闭虚拟机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆