@@ -6,6 +6,8 @@ import android.content.Intent
66import android.content.pm.PackageManager
77import android.graphics.Color
88import android.graphics.drawable.ColorDrawable
9+ import android.net.Uri
10+ import android.provider.ContactsContract
911import android.support.v4.content.ContextCompat
1012import android.view.View
1113import android.widget.ListView
@@ -58,12 +60,12 @@ class MVPMediator : ToolbarMediator() {
5860 }
5961
6062 private fun pickContact () {
61- // val pickContactIntent = Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"))
62- // pickContactIntent.type = Phone.CONTENT_TYPE // Show user only contacts w/ phone numbers
63- // startActivityForResult(pickContactIntent, 1001)
63+ val pickContactIntent = Intent (Intent .ACTION_PICK , Uri .parse(" content://contacts" ))
64+ pickContactIntent.type = ContactsContract . CommonDataKinds . Phone .CONTENT_TYPE // Show user only contacts w/ phone numbers
65+ startActivityForResult(pickContactIntent, 1001 )
6466
6567 // Here, thisActivity is the current activity
66- if (checkSelfPermission(Manifest .permission.READ_CONTACTS )
68+ /* if (checkSelfPermission(Manifest.permission.READ_CONTACTS)
6769 != PackageManager.PERMISSION_GRANTED) {
6870
6971 // Permission is not granted
@@ -83,7 +85,7 @@ class MVPMediator : ToolbarMediator() {
8385 }
8486 } else {
8587 // Permission has already been granted
86- }
88+ }*/
8789 }
8890
8991 override fun onActivityResult (requestCode : Int , resultCode : Int , data : Intent ? ) {
@@ -99,9 +101,11 @@ class MVPMediator : ToolbarMediator() {
99101 if ((grantResults.isNotEmpty() && grantResults[0 ] == PackageManager .PERMISSION_GRANTED )) {
100102 // permission was granted, yay! Do the
101103 // contacts-related task you need to do.
104+ activity.toast(" PERMISSION GRANTED" ).show()
102105 } else {
103106 // permission denied, boo! Disable the
104107 // functionality that depends on this permission.
108+ activity.toast(" PERMISSION DENIED" ).show()
105109 }
106110 return
107111 }
0 commit comments