次の方法で共有


BlockedNumberContract Class

Definition

The contract between the blockednumber provider and applications.

[Android.Runtime.Register("android/provider/BlockedNumberContract", ApiSince=24, DoNotGenerateAcw=true)]
public class BlockedNumberContract : Java.Lang.Object
[<Android.Runtime.Register("android/provider/BlockedNumberContract", ApiSince=24, DoNotGenerateAcw=true)>]
type BlockedNumberContract = class
    inherit Object
Inheritance
BlockedNumberContract
Attributes

Remarks

The contract between the blockednumber provider and applications. Contains definitions for the supported URIs and columns.

<h3> Overview </h3>

The content provider exposes a table containing blocked numbers. The columns and URIs for accessing this table are defined by the BlockedNumbers class. Messages, and calls from blocked numbers are discarded by the platform. Notifications upon provider changes can be received using a android.database.ContentObserver.

The platform will not block messages, and calls from emergency numbers as defined by android.telephony.PhoneNumberUtils#isEmergencyNumber(String). If the user contacts emergency services, number blocking is disabled by the platform for a duration defined by android.telephony.CarrierConfigManager#KEY_DURATION_BLOCKING_DISABLED_AFTER_EMERGENCY_INT.

<h3> Permissions </h3>

Only the system, the default SMS application, and the default phone app (See android.telecom.TelecomManager#getDefaultDialerPackage()), and carrier apps (See android.service.carrier.CarrierService) can read, and write to the blockednumber provider. However, #canCurrentUserBlockNumbers(Context) can be accessed by any application.

<h3> Data </h3>

Other than regular phone numbers, the blocked number provider can also store addresses (such as email) from which a user can receive messages, and calls. The blocked numbers are stored in the BlockedNumbers#COLUMN_ORIGINAL_NUMBER column. A normalized version of phone numbers (if normalization is possible) is stored in BlockedNumbers#COLUMN_E164_NUMBER column. The platform blocks calls, and messages from an address if it is present in in the BlockedNumbers#COLUMN_ORIGINAL_NUMBER column or if the E164 version of the address matches the BlockedNumbers#COLUMN_E164_NUMBER column.

<h3> Operations </h3> <dl> <dt><b>Insert</b></dt> <dd>

BlockedNumbers#COLUMN_ORIGINAL_NUMBER is a required column that needs to be populated. Apps can optionally provide the BlockedNumbers#COLUMN_E164_NUMBER which is the phone number's E164 representation. The provider automatically populates this column if the app does not provide it. Note that this column is not populated if normalization fails or if the address is not a phone number (eg: email).

Attempting to insert an existing blocked number (same BlockedNumbers#COLUMN_ORIGINAL_NUMBER column) will result in replacing the existing blocked number.

Examples:

ContentValues values = new ContentValues();
            values.put(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, "1234567890");
            Uri uri = getContentResolver().insert(BlockedNumbers.CONTENT_URI, values);
ContentValues values = new ContentValues();
            values.put(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, "1234567890");
            values.put(BlockedNumbers.COLUMN_E164_NUMBER, "+11234567890");
            Uri uri = getContentResolver().insert(BlockedNumbers.CONTENT_URI, values);
ContentValues values = new ContentValues();
            values.put(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, "12345@abdcde.com");
            Uri uri = getContentResolver().insert(BlockedNumbers.CONTENT_URI, values);

</p> </dd> <dt><b>Update</b></dt> <dd>

Updates are not supported. Use Delete, and Insert instead.

</dd> <dt><b>Delete</b></dt> <dd>

Deletions can be performed as follows:

ContentValues values = new ContentValues();
            values.put(BlockedNumbers.COLUMN_ORIGINAL_NUMBER, "1234567890");
            Uri uri = getContentResolver().insert(BlockedNumbers.CONTENT_URI, values);
            getContentResolver().delete(uri, null, null);

To check if a particular number is blocked, use the method #isBlocked(Context, String). </p> </dd> <dt><b>Query</b></dt> <dd>

All blocked numbers can be enumerated as follows:

Cursor c = getContentResolver().query(BlockedNumbers.CONTENT_URI,
                     new String[]{BlockedNumbers.COLUMN_ID, BlockedNumbers.COLUMN_ORIGINAL_NUMBER,
                     BlockedNumbers.COLUMN_E164_NUMBER}, null, null, null);

</p> </dd> <dt><b>Unblock</b></dt> <dd>

Use the method #unblock(Context, String) to unblock numbers.

</dd>

<h3> Multi-user </h3>

Apps must use the method #canCurrentUserBlockNumbers(Context) before performing any operation on the blocked number provider. If #canCurrentUserBlockNumbers(Context) returns false, all operations on the provider will fail with a SecurityException. The platform will block calls, and messages from numbers in the provider independent of the current user.

Java documentation for android.provider.BlockedNumberContract.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

BlockedNumberContract(IntPtr, JniHandleOwnership)

Fields

Authority

The authority for the blocked number provider

Properties

AuthorityUri

A content:// style uri to the authority for the blocked number provider

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass
ThresholdType

Methods

CanCurrentUserBlockNumbers(Context)

Checks if blocking numbers is supported for the current user.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
IsBlocked(Context, String)

Returns whether a given number is in the blocked list.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
Unblock(Context, String)

Unblocks the phoneNumber if it is blocked.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to