If you would like to design your own stickers for WhatsApp, you can package them in an Android app. You will need to distribute your app via the Google Play Store or another mechanism. Users who download and install your sticker app will be able to add your stickers to their WhatsApp sticker picker/tray, and start sending those stickers from within WhatsApp. A separate app is necessary and it will reside on your phone's home screen just like any other app. Stickers on WhatsApp must be legal, authorized, and acceptable. Learn more about acceptable use of our services at https://www.whatsapp.com/legal/#terms-of-service.
Sticker4W
...|https://www.b4x.com
Author: DonManfred
Version: 0.17
ATTENTION:
A few steps are required for your Stickers can be added to Whatsapp.
- See the tips for file-size redicing and creating webp Pictures.
- the contents.json must be in the Files folder.
- the pictures for the stickerpacks must be in a subfolder in the files folder. See Whatsapp-Documentation and Example.
- Add this to your Manifest
Add this Inline Java code to your Starter Service
Please read the README about anything about this Whatsapp feature.
This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
Please click here to donate for my work to write the wrapper (You can donate any amount you want )
Sticker4W
...|https://www.b4x.com
Author: DonManfred
Version: 0.17
- ContentFileParser
- Functions:
- Initialize (EventName As String)
- parseStickerPacks (contentsInputStream As java.io.InputStream) As java.util.List
- verifyStickerPackValidity (stickerPack As com.sticker4w.StickerPack)
- Initialize (EventName As String)
- Functions:
- StickerPackLoader
- Functions:
- fetchStickerAsset (identifier As String, name As String, contentResolver As android.content.ContentResolver) As Byte()
- fetchStickerPacks As java.util.List
- getStickerAssetUri (identifier As String, stickerName As String) As android.net.Uri
- Initialize (EventName As String)
- fetchStickerAsset (identifier As String, name As String, contentResolver As android.content.ContentResolver) As Byte()
- Functions:
- StickerProvider
- Functions:
- fetchStickerAsset (identifier As String, name As String, contentResolver As android.content.ContentResolver) As Byte()
- fetchStickerPacks (context As android.content.Context) As java.util.ArrayList
Get the list of sticker packs for the sticker content provider - getStickerAssetUri (identifier As String, stickerName As String) As android.net.Uri
- Initialize (EventName As String, Authority As String)
- fetchStickerAsset (identifier As String, name As String, contentResolver As android.content.ContentResolver) As Byte()
- Properties:
- Authority As String
- StickerPackList As java.util.List [read only]
- Authority As String
- Functions:
ATTENTION:
A few steps are required for your Stickers can be added to Whatsapp.
- See the tips for file-size redicing and creating webp Pictures.
- the contents.json must be in the Files folder.
- the pictures for the stickerpacks must be in a subfolder in the files folder. See Whatsapp-Documentation and Example.
- Add this to your Manifest
B4X:
AddApplicationText(
<provider
android:name="${applicationId}.starter$MyContentProvider"
android:authorities="${applicationId}.stickercontentprovider"
android:enabled="true"
android:exported="true"
android:readPermission="com.whatsapp.sticker.READ" />
)
Add this Inline Java code to your Starter Service
B4X:
#if Java
public static class MyContentProvider extends com.sticker4w.StickerContentProvider {
}
#End If
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private ion As Object
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim contparser As ContentFileParser
Dim loader As StickerPackLoader
Dim prov As StickerProvider
Private Button3 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
' From here the methods are not really needed
contparser.Initialize("")
Dim instr As InputStream
instr = File.OpenInput(File.DirAssets, "contents.json")
Log(contparser.parseStickerPacks(instr))
loader.Initialize("")
Log("loader.fetchStickerPacks")
Log(loader.fetchStickerPacks)
Dim packs As List = loader.fetchStickerPacks
Log(packs.Size)
Log(loader.getStickerAssetUri("1","Cuppy"))
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ion_Event (MethodName As String, Args() As Object) As Object
Log($"ion_Event(${MethodName}, ${Args(0)}, ${Args(1)})"$)
If Args(1) <> Null Then
Dim in As Intent = Args(1)
Log(in.GetData)
If in.HasExtra("validation_error") Then
Dim info As String = in.GetExtra("validation_error")
Log($"Validation-Error: ${info}"$)
End If
End If
'Args(0) = resultCode
'Args(1) = intent
Return Null
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetField("processBA")
End Sub
Sub Button3_Click
Dim in As Intent
in.Initialize("com.whatsapp.intent.action.ENABLE_STICKER_PACK", "")
in.putExtra("sticker_pack_id", "1") ' Identifier of the StickerPack. The Files of this pack must be in a subfolder named "1" in the Filesfolder. Depends on the entry in the json file
in.putExtra("sticker_pack_authority", "de.donmanfred.sticker.stickercontentprovider")
in.putExtra("sticker_pack_name", "Cuppy")
in.Flags = 1
'Try
StartActivityForResult(in)
End Sub
Please read the README about anything about this Whatsapp feature.
This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
Please click here to donate for my work to write the wrapper (You can donate any amount you want )
Attachments
Last edited: