0

I want to port an AppcompatActivity to a BaseActivity.

I tried to do so but I was unable to solve. I am new to android developemnt.

is it possible to do so? or I will have to do it othe way.

But I am unable to do so.

here is my code :

class MainActivity : BaseActivity() {

    private var dataFire: DataFire? = null
    private val mViewInflate: View? = null

    private val mRtcEngine: RtcEngine? = null
    private val mMuted = false

    private val TAG = VideoCallActivity::class.java.simpleName
    private var video_room_id: String? = null
    private val final_room_id: Long = 0
    private val tvUsernameVideoChat: TextView? = null
    var userIDvisited: String? = null

    private val videoFragment = VideoFragment.newInstance()

    override fun getLayoutId() = R.layout.main_activity

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        try {
            if (savedInstanceState == null) {
                getReplaceFragmentTransaction(R.id.fragmentContainer, videoFragment, VideoFragment.TAG).commit()
            }
        } catch (e: Exception) {
            Log.e("name_MainActivity", e.message.toString())
        }
    }

    override fun onBackPressed() {
        super.onBackPressed()
        //Todo: endCall()
        RtcEngine.destroy()
    }
}

thanks in advance.

Devid John
  • 23
  • 7
  • you haven't posted what `BaseActivity` is – a_local_nobody Jan 11 '21 at 06:53
  • and your intro and title are misleading : `How to convert baseActivity to AppCompatActivity` and `I want to port an AppcompatActivity to a BaseActivity.` – a_local_nobody Jan 11 '21 at 06:58
  • You cannot convert an AppCompactActivity to BaseActivity from the [docs](https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity) there is no inheritance between them. If you are trying to pass information between them read [this](https://stackoverflow.com/questions/16036572/how-to-pass-values-between-fragments) thread – Sync it Jan 11 '21 at 07:36

1 Answers1

1

you must define Base Activity

abstract class BaseActivity : Activity() {
fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(layoutResourceId)
}

protected abstract val layoutResourceId: Int

}

Fahime Zivdar
  • 341
  • 2
  • 9