通过图标轻拍颤动打开设备上的通讯录 [英] Open Contacts on device via icon tap flutter
本文介绍了通过图标轻拍颤动打开设备上的通讯录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过扑动中的图标来打开设备上的联系人?我可以使用url_launcher的插件打开电话功能.我已经使用了通讯录插件,但是我们不需要从应用程序中管理通讯录,我们想使用电话功能来管理通讯录.
Is it possible to open the contacts on a device from an icon tap in flutter? I am able to open the phone function using url_launcher's plugin.I have used the contacts plugin but we dont have a need to manage contacts from our application, we want to use the phones functionality for managing contacts.
推荐答案
您可以使用Flutter Intent.ACTION_VIEW 意向.
You can achieve this using Flutter platform channels and android Intent.ACTION_VIEW intent.
例如,在您的 MainActivity
中注册新频道并启动Contacts活动:
For example in your MainActivity
register new channel and launch Contacts activity:
MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result ->
launchContactActivity()
}
private fun launchContactActivity() {
val intent = Intent(Intent.ACTION_VIEW)
intent.type = ContactsContract.Contacts.CONTENT_TYPE
startActivityForResult(intent, REQUEST_CODE)
}
在颤抖的一面:
void launchContacts() async {
try {
await platform.invokeMethod('launch');
} on PlatformException catch (e) {
print("Failed to launch contacts: ${e.message}");
}
setState(() {
});
}
请参见完整示例.希望有帮助.
这篇关于通过图标轻拍颤动打开设备上的通讯录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文