Android Question Minimal B4A sample project that qualifies as default SMS app and appears in the default SMS selection list

OMS

Member
Hi everyone,

I'm trying to make my B4A app eligible to be selected as the default SMS app on Android (KitKat and above). I've added all the required permissions, receivers, service and intent-filters, but my app still doesn't appear in the list when another SMS app (like Google Messages) prompts the user to choose a default, and it's not listed in Settings > Apps > Default apps > SMS app.

The official Google Messages and Samsung Messages apps show up fine, but mine doesn't.

Could someone please share a minimal working B4A sample project (or just the full Manifest code + any required services/receivers) that:
  • Successfully appears in the default SMS app selection dialog
  • Is recognized by Telephony.Sms.getDefaultSmsPackage()
  • Can be set as the default SMS app

I don't need full messaging functionality — just the bare minimum to make Android consider it a valid SMS app.

Any help or a small zip of a working example would be greatly appreciated!

Thanks in advance.
 

OMS

Member
Hi Erel and everyone,

I wanted to give a final update and share the solution that worked for me.
Device: Samsung Galaxy A35 – Android 16 (One UI 8)

After many tests, my app now successfully appears in the default SMS list (Settings > Apps > Default apps > SMS app) together with Google Messages and Samsung Messages. When I open Google Messages while it's not default, the selection dialog appears and my app is also listed there.

I worked on TestSMSdefaultapp.zip sample (post #28 in the linked thread with minor changes):
However, on this newer Samsung device, calling RoleManager.createRequestRoleIntent("android.app.role.SMS") from inside my own app does nothing – no dialog appears at all.

The reliable workaround is to open the Default apps settings page directly and let the user choose manually:

basic
B4X:
Sub RequestDefaultSms
    Dim i As Intent
    Dim P As Phone
    Dim sdk As Int = P.SdkVersion
    Log("Sdk Version ==> " & sdk)
    If sdk >= 29 Then
        Dim jo As JavaObject
        jo.InitializeContext
        Dim roleManager As JavaObject = jo.RunMethod("getSystemService", Array("role"))
       
        If roleManager.RunMethod("isRoleAvailable", Array("android.app.role.SMS")) Then
            Log("android.app.role.SMS is Available")
            If Not(roleManager.RunMethod("isRoleHeld", Array("android.app.role.SMS"))) Then
'                Dim requestIntent As Intent
'                requestIntent = roleManager.RunMethod("createRequestRoleIntent", Array("android.app.role.SMS"))
'                StartActivity(requestIntent)
           
                i.Initialize("android.settings.MANAGE_DEFAULT_APPS_SETTINGS", "")
                StartActivity(i)
                ToastMessageShow("In DEFAULT APPS page, find the 'SMS app' section and select your own application.", True)
            Else
                Log("isRoleHeld")
            End If
        Else
            Log("android.app.role.SMS is not Available")
        End If
    Else  
        i.Initialize("android.provider.Telephony.ACTION_CHANGE_DEFAULT", "")
        i.PutExtra("package", Application.PackageName)
        StartActivity(i)
    End If
End Sub

This opens Settings > Apps > Default apps directly, where my app is visible and can be selected without any problem.

I've attached a minimal working project (exported as zip from B4A) that demonstrates this. It includes the full manifest setup and the code to guide the user to the settings page.

Thank you very much Erel for the original sample and the help – it was the key to getting the app qualified!

Hope this helps others with newer Samsung devices.



 

Attachments

  • TestSMSdefautapp.zip
    58.4 KB · Views: 6
Upvote 0
Top