Android Question No Activity found to handle Intent

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.

In my app user can make a phone call to the office.

Here is a code
B4X:
If Phone.ToLowerCase.Contains("ext.") Then
            
            Phone=Phone.ToLowerCase.Replace("ext.",",")
            
        End If

        Phone=Phone.Replace("(","")
        Phone=Phone.Replace(")","")
        Phone=Phone.Replace("-","")
        Phone=Phone.Replace(" ","")
        
        If Phone.SubString2(0,1)<>"1" Then
            Phone="1" & Phone
        End If
                    
            
        Dim i As Intent
        i.Initialize(i.ACTION_VIEW, "tel:" & Phone)
        StartActivity(i)

On some phones it show an error -
android.content.ActivityNotFoundException: No Activity found to handle Intent { actandroid.intent.action.VIEW dattel:xxxxxxxxx-xxxx flg0x20000 }

I tried on few of my phones and even on a tablet without a SIM card - no errors.

It doesn't need any permissions.

Have ever seen this error?
 

drgottjr

Expert
Licensed User
Longtime User
the error means there is no default dialer on those devices which report the error. ACTION_VIEW (and ACTION_DIAL) will launch the dialer.
if you use ACTION_CALL, your app makes the call (but you'll need call permission).
can you check with any users of those devices and ask them how they would normally make a phone call? which devices are they using?
to make the user experience more friendly, you might want to wrap startactivity() in a try/catch block. if catch is triggered, you can show some kind of message to explain the situation instead of the clinical exception message. it might also give you the chance to try again (perhaps using ACTION_CALL this time)
 
Upvote 0
Top