when I am trying to click on an element on the reycler view it creates a new intent in the fragment and calls a different Activity but when it starts the new activity from the intent it just doesnt display anything or the breakpoint at SecondaryActivity shows up
this code is running from a fragment on the main activity and the new activity isnt displaying any layout
fun loadImages(){
recyclerView!!.setHasFixedSize(true)
recyclerView!!.layoutManager = GridLayoutManager(this.activity,4)
try {
this.imageList = ImageGallery.GetImagesList(this.context as Context )
}
catch (ex:Exception)
{
println(ex.message)
}
try { galleryAdapter = GalleryAdapter(this.context as Context,imageList,
object : IPhotoInterface {
override fun onPhotoClick(stringPath: String):Unit {
//process picture on click
imageIntent = android.content.Intent(context,SecondaryActivity::class.java)
imageIntent.putExtra("image_file",File(stringPath))
try{
startActivity(imageIntent)//here throws and exception
}catch(except:Exception)
{
println(except.message)
}
}
})
recyclerView?.adapter = galleryAdapter
galleryNumberText?.text = "${imageList.size} images"
}
catch(ex:Exception)
{
println(ex.message)
}
}
secondary_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<include layout="@layout/secondary_action_bar"></include>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gearicon"
app:flow_verticalAlign="center"
tools:ignore="MissingConstraints">
</ImageView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="407dp"
android:id="@+id/bottomNavBar"
android:layout_height="57dp"
android:layout_marginTop="32dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.461"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="1.0"
android:background="@color/black"
app:menu="@menu/bottom_navigation_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.drawerlayout.widget.DrawerLayout>
SecondaryActivity
kt
class SecondaryActivity: AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
super.onCreate(savedInstanceState, persistentState)
val i = intent
val myParcelableObject: File? =
i.getParcelableExtra<Parcelable>("image_file") as File?
}
}