Intent intent=new Intent(MainActivity.this, ContactListActivity.class);
                        startActivity(intent);


MainActivity.this用Java编写,ContactListActivity用kotlin编写。我试图调用ContactListActivty,但最终收到错误消息

 have you declared this activity in your AndroidManifest.xml?


我还在清单文件中添加了活动。

 <activity android:name="Chat_Activity$Connections$ContactListActivity"
            android:parentActivityName=".MainActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity"/>
        </activity>


编辑:

ContactListActivity.kt

class ContactListActivity : AppCompatActivity() {

    private var mBroadcastReceiver: BroadcastReceiver? = null
    private val TAG:String="ContactListActivity"

    //static variable
    object Obz{
        @JvmStatic val GetContactListFromServer:String="Contact List"
    }

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


        title = "Contact list"

        contact_list.hasFixedSize()
        contact_list.layoutManager= LinearLayoutManager(this)

        getContactListAndNextActivity()
    }

    fun getContactListAndNextActivity(){

        contact_list.adapter= ContactListAdaptor(applicationContext, dbHelper(applicationContext).getContactList())

    }

}

最佳答案

您的清单name条目看起来可疑。

android:name="Chat_Activity$Connections$ContactListActivity"

我不确定完全限定的路径名​​是什么,但是请尝试:

android:name=".ContactListActivity"

要么

android:name="<qualified.path.to>.ContactListActivity"

10-08 03:42