Я хочу работать как приложение для обмена сообщениями по умолчанию, и для этого мне приходится самостоятельно обрабатывать входящие и исходящие SMS. Когда вы вставляете SMS в БД, вы должны указать THREAD_ID
. При просмотре через Telephony
класс я нашел эту функциюПолучение THREAD_ID с использованием Telephony.Threads класс больше не работает
/**
* This is a single-recipient version of {@code getOrCreateThreadId}.
* It's convenient for use with SMS messages.
* @param context the context object to use.
* @param recipient the recipient to send to.
* @hide
*/
public static long getOrCreateThreadId(Context context, String recipient) {
Set<String> recipients = new HashSet<String>();
recipients.add(recipient);
return getOrCreateThreadId(context, recipients);
}
/**
* Given the recipients list and subject of an unsaved message,
* return its thread ID. If the message starts a new thread,
* allocate a new thread ID. Otherwise, use the appropriate
* existing thread ID.
*
* <p>Find the thread ID of the same set of recipients (in any order,
* without any additions). If one is found, return it. Otherwise,
* return a unique thread ID.</p>
* @hide
*/
public static long getOrCreateThreadId(
Context context, Set<String> recipients) {
Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
...
...
Теперь функция скрыта от @hide
(я думаю). Я больше не могу получить к нему доступ. Я могу воспроизвести функциональность в своем коде, но хотел знать правильный способ получить THREAD_ID
.