Answer the question
In order to leave comments, you need to log in
What is the right way to implement Content Provider in my little code?
I get a list of contacts from my phone and I want to transfer the received list through the Intent to the activity. To then use it in recyclerView. But I don’t catch up on how to do it. Because I don't understand what type of change.
result in the end.
class AsyncService() : IntentService("MyAsyncService") {
override fun onHandleIntent(intent: Intent?) {
var cols = arrayListOf<String>(
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER).toTypedArray()
var result = contentResolver.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
cols,
null,
null,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
)
val intent = Intent("your_action")
intent.putExtra("key", result.toString())
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
}
}
val response = intent.getStringExtra("key")
Answer the question
In order to leave comments, you need to log in
Why is there a service? Do the same in activation. Just take it to another thread.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question