0
アンドロイドスタジオのTelephonyManagerを使用してデバイスからモバイル番号を取得したい場合、バージョン4.0で取得できますが、 6.0TelephonyManagerを使用してアンドロイドバージョン6.0からモバイル番号を取得すると、最低バージョンで動作します
アンドロイドスタジオのTelephonyManagerを使用してデバイスからモバイル番号を取得したい場合、バージョン4.0で取得できますが、 6.0TelephonyManagerを使用してアンドロイドバージョン6.0からモバイル番号を取得すると、最低バージョンで動作します
ユーザーがバージョン6.0でTelephonyManagerの許可を得ているかどうかを確認する必要があります。アプリがユーザーの連絡先の読み取り権限を持っており、必要に応じて権限を要求する場合は、次のコードをチェック詳細link
を確認することができます。
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
@usha:uはそれを確認しました – DKV
ユーザーが許可を与えた場合、彼の連絡先にはどうすれば – Usha
@ Ushaにアクセスできますか?以下のバージョンと同じです。 – DKV