Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.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_Eclipse_Timer - Fatal编程技术网

Java 未在清单中声明的活动(显然)

Java 未在清单中声明的活动(显然),java,android,eclipse,timer,Java,Android,Eclipse,Timer,我一辈子都不明白为什么它总是说“找不到显式活动类com.example.timer.beep。你在Android清单中声明了活动了吗?”。据我所知,它已经被声明了,我遵循了我构建的最后一个小应用程序的惯例。我的xml文件是小写的,我的.java文件是CamelCase。有没有人有任何其他的想法,为什么它会给我这个错误?错误出现在MainActivity.java中的readyToBeep函数中 Main Activity.java package com.example.timer; imp

我一辈子都不明白为什么它总是说“找不到显式活动类com.example.timer.beep。你在Android清单中声明了活动了吗?”。据我所知,它已经被声明了,我遵循了我构建的最后一个小应用程序的惯例。我的xml文件是小写的,我的.java文件是CamelCase。有没有人有任何其他的想法,为什么它会给我这个错误?错误出现在MainActivity.java中的readyToBeep函数中

Main Activity.java

package com.example.timer;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public void readyToBeep(View v)
{
    Intent intent = new Intent(this, Beep.class);
    startActivity(intent);

}

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

}
Beep.java

package com.example.timer;

import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;

public class Beep extends Activity {

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.buzz);
}

private Context Context;
 Timer timer;

 public Beep(){};

    public Beep(Context Context) {

this.Context = Context;
        timer = new Timer();
        timer.schedule(new RemindTask(),
                   0,        //initial delay
                   1*1500);  //subsequent rate
     }

      class RemindTask extends TimerTask {


          public void run() {


            MediaPlayer mPlayer = MediaPlayer.create(Context, R.raw.beep);  
            mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mPlayer.start();      

        }    

    }

    public void main(String args[]) {

          new Beep();
            }       
}
显示

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.timer"
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/AppTheme" >
    <activity
        android:name="com.example.timer.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

   <activity android:name="com.example.timer.buzz" >
    </activity>

</application>

</manifest>

短暂性脑缺血发作

您的清单中没有关于您的
Beep
活动的声明。加上:

<activity android:name="com.example.timer.Beep" >
</activity>


它显然不在清单中。面团!!休眠,与实际布局名称关联的活动。
<activity android:name="com.example.timer.Beep" >
</activity>