如何以编程方式在android 10中恢复已删除的联系人

问题描述

我想创建一个可以恢复已删除联系人的应用。它可以在所有其他设备上工作,但在android 10中该应用无法获取已删除的联系人。有什么解决方案可以从android 10中获取已删除的联系人。

这是我的代码,可以恢复已删除的联系人

public static final String WHERE_MODIFIED1 = "( " + ContactsContract.RawContacts.DELETED + "=1)";
ContentResolver cr = getContentResolver();
    Cursor cur = cr.query((ContactsContract.RawContacts.CONTENT_URI),null,WHERE_MODIFIED1,(DeletedContactRecovery.hasHoneycomb() ? "sort_key" : "display_name") + " COLLATE LOCALIZED ASC");

    assert cur != null;
    if (cur.getCount() > 0) {
        while (cur.moveToNext()) {
            String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
            String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
            String phone = null;
            //if (!(Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0)) {
            System.out.println("name : " + name + ",ID : " + id);

            // get the phone number
            Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",new String[]{id},null);
            assert pCur != null;
            while (pCur.moveToNext()) {
                phone = pCur.getString(
                        pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                System.out.println("phone" + phone);
            }
            pCur.close();
            //}
            if (id != null) {
                contactList.add(new Contact(name,phone,id));
            }
            Log.e("hvy","onCreaterrView  Phone Number: name = " + name
                    + " No = " + phone);
        }
    }
    cur.close();

解决方法

对于要阻止或恢复联系人的Android应用程序,有必要将其设置为默认的Dailer或SMS应用程序。当我厌倦了阅读android 10中的阻止联系人时,即使我的应用程序在android 10下也能正常工作,我也遇到过同样的问题。阅读联系人。

,

我认为您无法执行此操作,因为您无权访问应用程序特殊空间。 每个应用程序都有一个特殊的空间,其他应用程序无法访问它。

可以通过root foreach($request->name as $key => $skill){ $user->skillUser()->attach($skill,[ 'name' => $request->name[$key],'level' => $request->level[$key],]); } 来恢复联系。

转到user并启用Developer Options,则需要一个用于控制root请求的应用程序,例如kingo root

,

您可以使用此应用恢复已删除的联系人 https://play.google.com/store/apps/details?id=com.my.recovermycontacts

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...