Android Question Sim Card

Terradrones

Active Member
Licensed User
Hi All

I need some advice\help please.

In South Africa most of us are on a prepaid cellphone system. When using NTRIP with a GPS we need to use the cellphone service provider network which costs money and is paid for by the data that we buy. No data on cellphone = no NTRIP corrections.

Is there a way one can enquire what the balance is of the data on your Sim Card?

I have looked at the Simcard library, but there is no function available to do it.

It would be nice to be able to stay in the program and enquire the balance on one's simcard without having to exit the program and dialling #111*

Thanks
Michael
 

teddybear

Well-Known Member
Licensed User
There is no the balance is of the data on your Sim Card, the data is on the server of the service provider. you can dial #111 using your app for the message
 
Upvote 0

Terradrones

Active Member
Licensed User
Hi

Ok, I figured it out to read my Sim Card. The only problem is that I cannot read the Sim Card phone number.

Code:
B4X:
Sub Butt2_Click
    CleanPanels
    Panel1.Visible=True
End Sub

Sub Butt1_Click
    Dim Intent As Intent
    
    Try
        If Label34.Text.ToLowerCase.Contains("vodacom") Then
            'Vodacom
            Intent.Initialize(Intent.ACTION_CALL, "tel:*111%23")
        Else If Label34.Text.ToLowerCase.Contains("mtn") Then
            'MTN
            Intent.Initialize(Intent.ACTION_CALL, "tel:*136%23")
        Else If Label34.Text.ToLowerCase.Contains("cell c") Then
            'Cell C
            Intent.Initialize(Intent.ACTION_CALL, "tel:*101%23")
        End If
    Catch
        Msgbox2Async("Your Call Was Unsuccesful","No Connection","OK","","",Null,False)
    End Try
        
    ' Start the activity to dial the number
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        Try
            StartActivity(Intent)
        Catch
            Msgbox2Async("There Is No Sim Card In Your Controller","No Sim Card","OK","","",Null,False)
        End Try
    End If
End Sub

Sub AboutPhone
    rp.CheckAndRequest(rp.PERMISSION_READ_PHONE_STATE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        Try
            sim.Initialize

            Label21.Text=p.Manufacturer.ToUpperCase
            Label29.Text=p.Model.ToUpperCase
            Label36.Text = sim.GetNetworkCountryIso.ToUpperCase
            Label23.Text = sim.GetPhoneType.ToUpperCase
            Label27.Text = sim.GetSimState.ToUpperCase
            Label31.Text = sim.IsNetworkRoaming
            Label31.Text = Label31.Text.ToUpperCase
            Label34.Text = sim.GetNetworkOperatorName.ToUpperCase
            Label38.Text = sim.GetLine1Number.ToUpperCase
        Catch
            Log(LastException)
        End Try
    End If

End Sub
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Hi

Ok, I figured it out to read my Sim Card. The only problem is that I cannot read the Sim Card phone number.
What is your targetSdkVersion?
Android 10+, you can't read phone number from your sim card.
Try GetLine1Number using PhoneId.
I'm curious why you want to get the phone number.
 
Upvote 0

Terradrones

Active Member
Licensed User
A Surveyor is a funny Creature. The more info the Surveyor has the happier he\she is. The phone number was just to display more info on the screen.

With this routine the Surveyor can access either Vodacom, MTN or Cell C directly in the program to check the data balance or even recharge the Phone.

In South Africa NTRIP is free of charge, but you pay for the data that you use.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
What is your targetSdkVersion?
Android 10+, you can't read phone number from your sim card.
Try GetLine1Number using PhoneId.
I'm curious why you want to get the phone number.
You only answered the question I'm curious
targetSdkVersion?
GetLine1Number using PhoneId.?
 
Upvote 0

Terradrones

Active Member
Licensed User
I will try the PhoneId tomorrow. I must still complete the processing of my Aerial Drone Survey (5200 hectares).

My targetSdkVersion = 28
 
Upvote 0
Top