Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.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 &引用;安卓应用程序“;停止_Java_Android - Fatal编程技术网

Java &引用;安卓应用程序“;停止

Java &引用;安卓应用程序“;停止,java,android,Java,Android,我正在关注Newboston的教程(Android应用程序开发),但我制作的应用程序在运行一个类(splash)文件后崩溃 在splash类之后,将运行menu类,然后运行MainActivity,然后是textplay 我正在为所有类编写代码。看看你能不能找到这里出了什么问题 飞溅类 package com.example.testing; import android.app.Activity; import android.content.Intent; import andro

我正在关注Newboston的教程(Android应用程序开发),但我制作的应用程序在运行一个类(splash)文件后崩溃

在splash类之后,将运行menu类,然后运行MainActivity,然后是textplay

我正在为所有类编写代码。看看你能不能找到这里出了什么问题

飞溅类

 package com.example.testing;

 import android.app.Activity;
 import android.content.Intent;
 import android.media.MediaPlayer;
 import android.os.Bundle;

public class Splash extends Activity {
    MediaPlayer ourSong;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        ourSong = MediaPlayer.create(Splash.this,R.raw.sound);
        ourSong.start();
        Thread timer=new Thread(){
        public void run(){
            try{
                sleep(5000);
                }catch(InterruptedException e){
                    e.printStackTrace();
                }finally{
                    Intent openStartingPoint=
                              new Intent("com.example.testing.Menu");

                    startActivity(openStartingPoint);
                }
                    }
    };timer.start();
}
    protected void onPause(){
                super.onPause();
                ourSong.release();
                finish();
                }
}
菜单类

package com.example.testing;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Menu extends ListActivity {

    String classes[]={"MainActivity","TextPlay","example2","example3","example4","example5"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(Menu.this,android.R.layout.simple_list_item_1,classes));
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        String cheese=classes[position];
        try {
             Class ourClass = Class.forName("com.example.testing."+ cheese);
            Intent ourIntent=new Intent(Menu.this , ourClass);
            startActivity(ourIntent);
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }





}
文本播放类

package com.example.testing;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

public class TextPlay extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.text);

        Button chkCmd = (Button) findViewById (R.id.bResults);
        final ToggleButton passTog = (ToggleButton) findViewById (R.id.tbPassword);
        EditText input =(EditText) findViewById (R.id.etCommands);
        TextView display = (TextView) findViewById (R.id.tvResults);
        passTog.setOnClickListener(new View.OnClickListener() {


            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                if(passTog.isChecked()){

                }
                else{
                    }
                }
        });
    }



}
试试这个

您可能会在这里获得
android.content.ActivityNotFoundException
Intent openStartingPoint=newintent(“com.example.testing.Menu”)最后更改您的如下所示

finally{
        Intent openStartingPoint=new Intent(Splash.this,Menu.class);
        startActivity(openStartingPoint);
}
而不是这个用途-

 Intent openStartingPoint=new Intent(Splash.this,Menu.class);

希望这能有所帮助。

将您的错误日志发布到此处xx更改此操作后,它就起作用了。您能解释一下由于哪个应用程序正在停止而导致上述代码行出现的问题吗?构造函数意图(字符串操作)用于为操作创建意图,例如,意图意图意图=新意图(Intent.action\u视图)
 Intent openStartingPoint=new Intent("com.example.testing.Menu");
 Intent openStartingPoint=new Intent(Splash.this,Menu.class);