Jorge Leonardo
Jorge Leonardo

Reputation: 175

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

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

enter image description here

The problem (I try to call MainActivity cardView and it only shows two activities) enter image description here

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
            }
        }

    }
}

Upvotes: 0

Views: 1365

Answers (1)

paule mandengue
paule mandengue

Reputation: 64

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

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

Upvotes: 1

Related Questions