0
我嘗試使用聯繫人時遇到問題。我使用下面的代碼添加新的Comtacts,它工作正常。但是,如果我在「添加聯繫人」屏幕上按下「後退」按鈕,則會添加聯繫人,就像我按了「完成」/「保存」一樣。我能做些什麼,以便Back被視爲取消而不是完成/保存?謝謝。聯繫人問題Contracts.Intents.SHOW_OR_CREATE_CONTACT
Intent i = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, Uri.parse(String.format("tel: %s", number)));
i.addCategory(Intent.CATEGORY_DEFAULT);
i.putExtra(ContactsContract.Intents.EXTRA_FORCE_CREATE, true);
i.putExtra(ContactsContract.Intents.Insert.NAME, name);
i.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_WORK);
i.putExtra(ContactsContract.Intents.Insert.PHONE, number);
startActivity(i);