Android Question Create a whatsapp sticker pack

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
I m trying to add a sticker pack on whatsapp via b4a.
this can be made with intent / file provider and manifest.

Here is the oficial android api
https://github.com/WhatsApp/stickers/blob/master/Android/README.md

on the final of page have a intent example and manifest

here is what whatsapp say to make

The ContentProvider needs to have a read permission of com.whatsapp.sticker.READ in AndroidManifest.xml. It also needs to be exported and enabled. See below for an example:

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


here is what i m trying to make on manifest

B4X:
AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.stickercontentprovider"
  android:enabled="true"
  android:exported="false"
  android:readPermission="com.whatsapp.sticker.READ"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)

CreateResource(xml, provider_paths,
   <files-path name="name" path="stickers"/>
)



and later the is the intent part.
here is the whatsapp example
B4X:
    Intent intent = new Intent();
    intent.setAction("com.whatsapp.intent.action.ENABLE_STICKER_PACK");
    intent.putExtra("sticker_pack_id", identifier); //identifier is the pack's identifier in contents.json file
    intent.putExtra("sticker_pack_authority", authority); //authority is the ContentProvider's authority. In the case of the sample app it is BuildConfig.CONTENT_PROVIDER_AUTHORITY.
    intent.putExtra("sticker_pack_name", stickerPackName); //stickerPackName is the name of the sticker pack.
    try {
        startActivityForResult(intent, 200);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, R.string.error_adding_sticker_pack, Toast.LENGTH_LONG).show();
    }


and here is what i m trying

B4X:
Sub Sticker_Whatsapp
    Dim json As String = "contents.json"
    Dim img1 As String = "1.webp"
    Dim img2 As String = "2.webp"
    Dim img3 As String = "3.webp"
    Dim img4 As String = "4.webp"
    Dim img5 As String = "5.webp"
    Dim img6 As String = "6.webp"
    Dim img7 As String = "7.webp"
    Dim img8 As String = "8.webp"
    Dim img9 As String = "9.webp"
    Dim imgPrincipal As String = "tray_bolsonaro.png"
    File.Copy(File.DirAssets, json, Starter.Provider.SharedFolder, json)
    File.Copy(File.DirAssets, img1, Starter.Provider.SharedFolder, img1)
    File.Copy(File.DirAssets, img2, Starter.Provider.SharedFolder, img2)
    File.Copy(File.DirAssets, img3, Starter.Provider.SharedFolder, img3)
    File.Copy(File.DirAssets, img4, Starter.Provider.SharedFolder, img4)
    File.Copy(File.DirAssets, img5, Starter.Provider.SharedFolder, img5)
    File.Copy(File.DirAssets, img6, Starter.Provider.SharedFolder, img6)
    File.Copy(File.DirAssets, img7, Starter.Provider.SharedFolder, img7)
    File.Copy(File.DirAssets, img8, Starter.Provider.SharedFolder, img8)
    File.Copy(File.DirAssets, img9, Starter.Provider.SharedFolder, img9)
    File.Copy(File.DirAssets, imgPrincipal, Starter.Provider.SharedFolder, imgPrincipal)
    

    File.MakeDir(Starter.Provider.SharedFolder,"bolsonaro")
    File.Copy(Starter.Provider.SharedFolder,json, Starter.Provider.SharedFolder&"/bolsonaro",json)
    File.Copy(Starter.Provider.SharedFolder,img1, Starter.Provider.SharedFolder&"/bolsonaro",img1)
    File.Copy(Starter.Provider.SharedFolder,img2, Starter.Provider.SharedFolder&"/bolsonaro",img2)
    File.Copy(Starter.Provider.SharedFolder,img3, Starter.Provider.SharedFolder&"/bolsonaro",img3)
    File.Copy(Starter.Provider.SharedFolder,img4, Starter.Provider.SharedFolder&"/bolsonaro",img4)
    File.Copy(Starter.Provider.SharedFolder,img5, Starter.Provider.SharedFolder&"/bolsonaro",img5)
    File.Copy(Starter.Provider.SharedFolder,img6, Starter.Provider.SharedFolder&"/bolsonaro",img6)
    File.Copy(Starter.Provider.SharedFolder,img7, Starter.Provider.SharedFolder&"/bolsonaro",img7)
    File.Copy(Starter.Provider.SharedFolder,img8, Starter.Provider.SharedFolder&"/bolsonaro",img8)
    File.Copy(Starter.Provider.SharedFolder,img9, Starter.Provider.SharedFolder&"/bolsonaro",img9)
    File.Copy(Starter.Provider.SharedFolder,imgPrincipal, Starter.Provider.SharedFolder&"/bolsonaro",imgPrincipal)
    
    
    
    
    
    Dim in As Intent
    in.Initialize("com.whatsapp.intent.action.ENABLE_STICKER_PACK", "")
    in.SetComponent("com.whatsapp.intent.action.ENABLE_STICKER_PACK")
    in.putExtra("sticker_pack_id", "bolsonaro")
    in.putExtra("sticker_pack_authority", "b4a.example.stickercontentprovider")
    in.putExtra("sticker_pack_name", "bolsonaro")
    
    in.Flags = 1
    Try
        StartActivity(in)
    Catch
        Log(LastException)
    End Try
End Sub



and i get this error

Error: There's a problem with this sticker pack and it can't be added to WhatsApp

WhatsApp Image 2018-11-16 at 16.21.12.jpeg



the whatsapp is detecting i m trying to add a sticker pack, i think the error is on the image paths or something like this.....

the json file and the images are Attached

ps: only show me this pop up. nothing more, no logs
what i m making wrong based on the whatsapp example?
 

Attachments

  • files.zip
    266.4 KB · Views: 413

DonManfred

Expert
Licensed User
Longtime User
this can be made with intent / file provider and manifest
Are you sure you are meaning "File Provider"?
Based on the Example link on Github it is using a ContentProvider.

public static final String CONTENT_PROVIDER_AUTHORITY = "com.example.samplestickerapp.stickercontentprovider";
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I am testing on Creating a wrapper but i ran into Issues. I´ve started a Question in the Java Questions Forum about it. Hopefully i can get some help ;-)

All in all it is more the new thing i can discover as i am Using Whatsapp a lot and i find the Idea of having my own Stickerset available here very interesting.
Out of curiosity i tried to build a wrap.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
I am testing on Creating a wrapper but i ran into Issues. I´ve started a Question in the Java Questions Forum about it. Hopefully i can get some help ;-)

All in all it is more the new thing i can discover as i am Using Whatsapp a lot and i find the Idea of having my own Stickerset available here very interesting.
Out of curiosity i tried to build a wrap.


Thanks @DonManfred. I Will donate 50 for u later this done. I tryed make an example but no success.
 
Upvote 0

alimanam3386

Active Member
Licensed User
Longtime User
Hi all.
I m trying to add a sticker pack on whatsapp via b4a.
this can be made with intent / file provider and manifest.

Here is the oficial android api
https://github.com/WhatsApp/stickers/blob/master/Android/README.md

on the final of page have a intent example and manifest

here is what whatsapp say to make



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


here is what i m trying to make on manifest

B4X:
AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.stickercontentprovider"
  android:enabled="true"
  android:exported="false"
  android:readPermission="com.whatsapp.sticker.READ"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)

CreateResource(xml, provider_paths,
   <files-path name="name" path="stickers"/>
)



and later the is the intent part.
here is the whatsapp example
B4X:
    Intent intent = new Intent();
    intent.setAction("com.whatsapp.intent.action.ENABLE_STICKER_PACK");
    intent.putExtra("sticker_pack_id", identifier); //identifier is the pack's identifier in contents.json file
    intent.putExtra("sticker_pack_authority", authority); //authority is the ContentProvider's authority. In the case of the sample app it is BuildConfig.CONTENT_PROVIDER_AUTHORITY.
    intent.putExtra("sticker_pack_name", stickerPackName); //stickerPackName is the name of the sticker pack.
    try {
        startActivityForResult(intent, 200);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, R.string.error_adding_sticker_pack, Toast.LENGTH_LONG).show();
    }


and here is what i m trying

B4X:
Sub Sticker_Whatsapp
    Dim json As String = "contents.json"
    Dim img1 As String = "1.webp"
    Dim img2 As String = "2.webp"
    Dim img3 As String = "3.webp"
    Dim img4 As String = "4.webp"
    Dim img5 As String = "5.webp"
    Dim img6 As String = "6.webp"
    Dim img7 As String = "7.webp"
    Dim img8 As String = "8.webp"
    Dim img9 As String = "9.webp"
    Dim imgPrincipal As String = "tray_bolsonaro.png"
    File.Copy(File.DirAssets, json, Starter.Provider.SharedFolder, json)
    File.Copy(File.DirAssets, img1, Starter.Provider.SharedFolder, img1)
    File.Copy(File.DirAssets, img2, Starter.Provider.SharedFolder, img2)
    File.Copy(File.DirAssets, img3, Starter.Provider.SharedFolder, img3)
    File.Copy(File.DirAssets, img4, Starter.Provider.SharedFolder, img4)
    File.Copy(File.DirAssets, img5, Starter.Provider.SharedFolder, img5)
    File.Copy(File.DirAssets, img6, Starter.Provider.SharedFolder, img6)
    File.Copy(File.DirAssets, img7, Starter.Provider.SharedFolder, img7)
    File.Copy(File.DirAssets, img8, Starter.Provider.SharedFolder, img8)
    File.Copy(File.DirAssets, img9, Starter.Provider.SharedFolder, img9)
    File.Copy(File.DirAssets, imgPrincipal, Starter.Provider.SharedFolder, imgPrincipal)
   

    File.MakeDir(Starter.Provider.SharedFolder,"bolsonaro")
    File.Copy(Starter.Provider.SharedFolder,json, Starter.Provider.SharedFolder&"/bolsonaro",json)
    File.Copy(Starter.Provider.SharedFolder,img1, Starter.Provider.SharedFolder&"/bolsonaro",img1)
    File.Copy(Starter.Provider.SharedFolder,img2, Starter.Provider.SharedFolder&"/bolsonaro",img2)
    File.Copy(Starter.Provider.SharedFolder,img3, Starter.Provider.SharedFolder&"/bolsonaro",img3)
    File.Copy(Starter.Provider.SharedFolder,img4, Starter.Provider.SharedFolder&"/bolsonaro",img4)
    File.Copy(Starter.Provider.SharedFolder,img5, Starter.Provider.SharedFolder&"/bolsonaro",img5)
    File.Copy(Starter.Provider.SharedFolder,img6, Starter.Provider.SharedFolder&"/bolsonaro",img6)
    File.Copy(Starter.Provider.SharedFolder,img7, Starter.Provider.SharedFolder&"/bolsonaro",img7)
    File.Copy(Starter.Provider.SharedFolder,img8, Starter.Provider.SharedFolder&"/bolsonaro",img8)
    File.Copy(Starter.Provider.SharedFolder,img9, Starter.Provider.SharedFolder&"/bolsonaro",img9)
    File.Copy(Starter.Provider.SharedFolder,imgPrincipal, Starter.Provider.SharedFolder&"/bolsonaro",imgPrincipal)
   
   
   
   
   
    Dim in As Intent
    in.Initialize("com.whatsapp.intent.action.ENABLE_STICKER_PACK", "")
    in.SetComponent("com.whatsapp.intent.action.ENABLE_STICKER_PACK")
    in.putExtra("sticker_pack_id", "bolsonaro")
    in.putExtra("sticker_pack_authority", "b4a.example.stickercontentprovider")
    in.putExtra("sticker_pack_name", "bolsonaro")
   
    in.Flags = 1
    Try
        StartActivity(in)
    Catch
        Log(LastException)
    End Try
End Sub



and i get this error



View attachment 74447


the whatsapp is detecting i m trying to add a sticker pack, i think the error is on the image paths or something like this.....

the json file and the images are Attached

ps: only show me this pop up. nothing more, no logs
what i m making wrong based on the whatsapp example?

do you mean emoji ? :confused: I wrapped this one

https://github.com/torindev/emoji
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
only show me this pop up
not for me :D

WhatsApp Image 2018-11-20 at 21.15.18.jpeg WhatsApp Image 2018-11-20 at 21.17.24.jpeg

To anyone who read this thread. The project in #1 does not work.
You need to create a ContentProvider together with a specific manifest entry and a small inline java class.
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0
Top