我们可以为WhatsApp Sticker应用程序实施多个内容提供商吗?

问题描述

由于我的要求是我的应用程序具有创建自定义贴纸和来自服务器的贴纸功能,导致单个问题,所以我尝试了很多添加多个内容提供商的问题,编辑配置 如下所示

enter image description here

  • 这就是我试图在清单中添加提供程序的方式

    Card(
                color: const Color(0xFF202020),child: Column(
                  children: [
                    ListTile(
                        title: const DecoratedBox(
                      decoration:
                          const Boxdecoration(color: const Color(0xFF141414)),child: const Text(
                        'John',style: TextStyle(color: const Color(0xFFE7E7E7)),),)),buttonbar(
                      alignment: MainAxisAlignment.start,children: [
                        FlatButton(
                            textColor: const Color(0xFFE7E7E7),onpressed: () {},child: const Text('Contact'))
                      ],)
                  ],
  • 应用级爬网

android {

     <provider
     android:name=".whats_app_based_code.provider.StickerContentProvider"
     android:authorities="${contentProviderAuthority}"
     android:enabled="true"
     android:exported="true"
     android:readPermission="com.whatsapp.sticker.READ">
 </provider>
 <provider
     android:name=".whats_app_based_code.provider.StickerContentProviderServer"
     android:authorities="${contentProviderAuthority}"
     android:enabled="true"
     android:exported="true"
     android:readPermission="com.whatsapp.sticker.READ">
 </provider>

解决方法

最后,我完成了这一部分,我添加了实现此目的的方法,因为像我这样的人可能希望将这样的功能添加到他们的应用中: 我实际上所做的是:

  • 我只在 App Level Gradle 中添加了一个内容提供商,并删除了另一个

  • 我通过清单添加了第二个内容提供程序,并像这样对完整的提供程序包进行了硬编码:

         <provider
         android:name=".whats_app_based_code.provider.StickerContentProvider"
         android:authorities="${contentProviderAuthority}"
         android:enabled="true"
         android:exported="true"
         android:readPermission="com.whatsapp.sticker.READ">
     </provider>
     <provider
         android:name=".whats_app_based_code.provider.StickerContentProviderServer"
         android:authorities="com.numan.stickersapp.whats_app_based_code.provider.WhatsAppLicensedCode.StickerContentProviderServer"
         android:enabled="true"
         android:exported="true"
         android:readPermission="com.whatsapp.sticker.READ">
     </provider>