我无法从一项活动切换到另一项,并且在清单文件中遇到问题。

huangapple go评论76阅读模式
英文:

I can't switch from one activity to another and I have a problem at the manisfest

问题

抱歉,你提供的代码和问题中包含了一些英文和代码,但我只能提供中文翻译。以下是翻译好的部分:

你说你的应用程序出现了问题,当尝试跳转到另一个活动时,应用程序崩溃了。在Logcat中,你看到了这个错误消息:android.content.ActivityNotFoundException: 无法找到显式活动类{com.example.project35cardview / com. example.proyecto35ca.MainActivitycardView};你是否在AndroidManifest.xml中声明了此活动?

你查看了清单文件,并尝试从清单文件中调用它,但只看到了两个活动。

在MainActivitycardView代码中,你创建了一个媒体播放器数组来处理音频文件,并设置了一些按钮点击事件来控制播放和暂停。你还有一个重复按钮,用于控制是否重复播放音轨。

如果需要更多帮助,请提出具体的问题或描述你需要的帮助。

英文:

Hello friend I have a problem with my intent, I am trying to go to another activity but my application is destroyed, in the logcat I see that mesaage (android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.project35cardview / com. example.proyecto35ca.MainActivitycardView}; have you declared this activity in your AndroidManifest.xml?)
I go to the manifest and I try to call it from the manifest and only two activities appear.

logcat

2020-08-08 07:15:11.600 28853-28853/? E/yecto35cardvie: Unknown bits set in runtime_flags: 0x8000
2020-08-08 07:15:11.663 28853-28853/? E/libc: Access denied finding property "runtime.mmitest.isrunning"
2020-08-08 07:15:12.117 28853-28888/com.example.proyecto35cardview E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@1108279
2020-08-08 07:15:12.119 28853-28888/com.example.proyecto35cardview E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@e5e9bbe
2020-08-08 07:15:15.146 28853-28853/com.example.proyecto35cardview E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.proyecto35cardview, PID: 28853
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.proyecto35cardview/com.example.proyecto35ca.MainActivitycardView}; have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2111)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1739)
        at android.app.Activity.startActivityForResult(Activity.java:5363)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
        at android.app.Activity.startActivityForResult(Activity.java:5304)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
        at android.app.Activity.startActivity(Activity.java:5734)
        at android.app.Activity.startActivity(Activity.java:5702)
        at com.example.proyecto35cardview.MainActivity$onCreate$2.onClick(MainActivity.kt:22)
        at android.view.View.performClick(View.java:7192)
        at android.view.View.performClickInternal(View.java:7166)
        at android.view.View.access$3500(View.java:824)
        at android.view.View$PerformClick.run(View.java:27592)
        at android.os.Handler.handleCallback(Handler.java:888)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:213)
        at android.app.ActivityThread.main(ActivityThread.java:8178)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

My code

 card_view.setOnClickListener {
          val intent = Intent (this,MainActivitycardView::class.java
            startActivity(intent)//line 22
            }

Manifest

我无法从一项活动切换到另一项,并且在清单文件中遇到问题。

The problem (I try to call MainActivity cardView and it only shows two activities)
我无法从一项活动切换到另一项,并且在清单文件中遇到问题。

MainActivitycardView

 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main_activitycard_view)

        //Se debe crear un vector de tipo MediaPlayer de 3 posiciones porque tengo 3 canciones
        val vectoMp3 = arrayOfNulls<MediaPlayer>(3)
        var repetir = 2
        var position = 0
        vectoMp3[0]= MediaPlayer.create(this,R.raw.race)
        vectoMp3[1] = MediaPlayer.create(this,R.raw.sound)
        vectoMp3[2]=MediaPlayer.create(this,R.raw.tea)

        //Metodo para pausar la canción
        buttonPlay.setOnClickListener {
            if (vectoMp3[position]?.isPlaying!!){
                vectoMp3[position]?.pause()
                //Metodo para cambiar imagen del boton
                buttonPlay.setBackgroundResource(R.drawable.reproducir)
                Toast.makeText(this ,"Pausa", Toast.LENGTH_SHORT).show()
            } else {
                vectoMp3[position]?.start()
                buttonPlay.setBackgroundResource(R.drawable.pausa)
                Toast.makeText(this ,"Play", Toast.LENGTH_SHORT).show()
            }
        }

        //Metodo para detener una canción
        buttonStop.setOnClickListener {
            if (vectoMp3[position] !=null){
                vectoMp3[position]?.stop()
                //Se debe colocar los vectores para que el boton  sepa que va a pausar
                vectoMp3[0]= MediaPlayer.create(this,R.raw.race)
                vectoMp3[1] = MediaPlayer.create(this,R.raw.sound)
                vectoMp3[2]=MediaPlayer.create(this,R.raw.tea)
                position = 0
                buttonPlay.setBackgroundResource(R.drawable.reproducir)
                //Metodo para volver a la portada 1
                imageView.setBackgroundResource(R.drawable.portada1)
                Toast.makeText(this, "Stop", Toast.LENGTH_SHORT).show()
            }
        }
        //Metodo para repetir una pista
        button4.setOnClickListener {
            if (repetir==1){
                button4.setBackgroundResource(R.drawable.no_repetir)
                Toast.makeText(this, "No repetor", Toast.LENGTH_SHORT).show()
                vectoMp3[position]?.isLooping  = false
                repetir = 2
            } else {
                button4.setBackgroundResource(R.drawable.repetir)
                Toast.makeText(this, "Repetir", Toast.LENGTH_SHORT).show()
                vectoMp3[position]?.isLooping  = true
                repetir = 1
            }
        }

    }
}

答案1

得分: 1

请显示您的MainActivitycardView.java类的定义。希望您将其扩展如下:

public class MainActivitycardView extends AppCompatActivity {
    //类的主体部分
}
英文:

Please show the definition of your class MainActivitycardView.java.
Hope you extended it like this :

public class MainActivitycardView extends AppCompatActivity { 
    //body of the class 
}

huangapple
  • 本文由 发表于 2020年8月8日 20:44:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/63315566.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定