Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我的应用程序在AVD中停止工作_Java_Android_Eclipse_Android Intent - Fatal编程技术网

Java 我的应用程序在AVD中停止工作

Java 我的应用程序在AVD中停止工作,java,android,eclipse,android-intent,Java,Android,Eclipse,Android Intent,我是新来的。 我没有任何错误警告,但当我测试时,它不幸停止工作。 我已经更改了AVD ram值,但仍然不起作用。 我试图将其导出到我的手机,但安装失败 我的活动文件 package com.abdo; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import andr

我是新来的。 我没有任何错误警告,但当我测试时,它不幸停止工作。 我已经更改了AVD ram值,但仍然不起作用。 我试图将其导出到我的手机,但安装失败

我的活动文件

package com.abdo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

 private static String logtag = "TwoButtonApp";//for use as the tag when logging 

 /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button buttonStart = (Button)findViewById(R.id.buttonStart);        
     buttonStart.setOnClickListener(startListener); // Register the onClick listener with the implementation above

     Button buttonStop = (Button)findViewById(R.id.buttonStop);        
     buttonStop.setOnClickListener(stopListener); // Register the onClick listener with the implementation above
    }

    //Create an anonymous implementation of OnClickListener
    private OnClickListener startListener = new OnClickListener() {
        public void onClick(View v) {
          Log.d(logtag,"onClick() called - start button");   
          Intent a = new Intent(MainActivity.this, ManuActivity.class);
          startActivity(a);

          Log.d(logtag,"onClick() ended - start button");
        }
    };

    // Create an anonymous implementation of OnClickListener
    private OnClickListener stopListener = new OnClickListener() {
        public void onClick(View v) {
         Log.d(logtag,"onClick() called - stop button"); 
         Toast.makeText(MainActivity.this, "The Stop button was clicked.", Toast.LENGTH_LONG).show();
          Log.d(logtag,"onClick() ended - stop button");
        } 
    };


    @Override
 protected void onStart() {//activity is started and visible to the user
  Log.d(logtag,"onStart() called");
  super.onStart();  
 }
 @Override
 protected void onResume() {//activity was resumed and is visible again
  Log.d(logtag,"onResume() called");
  super.onResume();

 }
 @Override
 protected void onPause() { //device goes to sleep or another activity appears
  Log.d(logtag,"onPause() called");//another activity is currently running (or user has pressed Home)
  super.onPause();

 }
 @Override
 protected void onStop() { //the activity is not visible anymore
  Log.d(logtag,"onStop() called");
  super.onStop();

 }
 @Override
 protected void onDestroy() {//android has killed this activity
   Log.d(logtag,"onDestroy() called");
   super.onDestroy();
 }
}
显示

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.abdo"
    android:versionCode="1"
    android:versionName="1.0" >

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


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/FullscreenTheme" >
        <activity
            android:name="com.abdo.MainActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.abdo.ManuActivity"
            android:label="@string/title_activity_manu" >
        </activity>
    </application>

</manifest>

  • 首先在清单文件中将android:debugable设置为true
  • 其次,在android设备的设置中打开
    install apk from unknown sources
    ,并在
    developer settings
    中打开
    allow to debug to through usb
    设置,或者类似的设置(不知道这如何调用英语,我有俄语界面)
  • 然后在调试模式下运行代码,按IDE中的
    debug
    按钮
并尝试在
super
函数调用之后编写代码

 @Override
 protected void onStart() {//activity is started and visible to the user
  super.onStart();  
  Log.d(logtag,"onStart() called");
 }

检查您的
logcat
是否有任何异常。