我正在开发一个android项目,但我一直无法将SMS消息加载到应用程序中。这是我遇到的错误:
我试图在此代码段中设置列表视图并使用数组适配器:
短信收件箱
private fun fetchInbox(): ArrayList<String> {
val sms: ArrayList<String> = ArrayList()
val uri: Uri = Uri.parse("contact://sms/inbox")
val cursor: Cursor = contentResolver.query(uri, arrayOf("id", "address", "date", "body"), null, null, null)
while (cursor.moveToNext()){
val address: String = cursor.getString(1)
val body: String = cursor.getString(3)
sms.add("Address: $address" + "Message: $body")
}
return sms
}
然后我在MainActivity中这样调用它:
val listView = text_Messages
if(fetchInbox() != null) {
val adapter: ArrayAdapter<String> = ArrayAdapter(this, android.R.layout.activity_list_item, fetchInbox())
listView.adapter = adapter
}
我只是不明白为什么会发生此错误
答案 0 :(得分:-1)
Linux XXXX 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
Python 2.7.12 (default, Oct 26 2016, 20:32:48)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> i = 17980346128496376037806642990182997031599635866559472356341845839069333332222333222233322323233222332233098899889887777666554544677778
>>> print i
17980346128496376037806642990182997031599635866559472356341845839069333332222333222233322323233222332233098899889887777666554544677778
>>> print i * 200
35960692256992752075613285980365994063199271733118944712683691678138666664
44466644446664464646644466446619779977977555533310908935555600
>>> print i * 200000000000000000000000000000
35960692256992752075613285980365994063199271733118944712683691678138666664
444666444466644646466444664466197799779775555333109089355556000000000000000
00000000000000
>>> print i * 20000000000000000000000000000022232112334
359606922569927520756132859804059681706925650761773870244766098830609978296
745510068184406058663546549318435451858026961579241750526563723815283805303
736457032014582329513852
>>> print sys.maxint
9223372036854775807