#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Private cr As ContentResolver
Type Apns ( nId As Long, cName As String, cApn As String )
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Main.lApp = True
If FirstTime Then
cr.Initialize("cr")
End If
If SeekApn( "claro1" ) = False Then
PutApn( "claro1", "ba.amx", "370", "02" )
End If
If SeekApn( "claro2" ) = False Then
PutApn( "claro2", "internet.ideasclaro.com.do", "370", "02" )
End If
If SeekApn( "orange" ) = False Then
PutApn( "orange", "orangenet.com.do", "370", "01" )
End If
ListApns
GetDefaultApn
Activity.Finish
End Sub
Sub Activity_Resume
Main.lApp = True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Main.lApp = False
End Sub
Sub ListApns
Dim oUri As Uri
Dim oList As List
Dim oBrow As List
Dim nRes As Long
Dim oApn As Apns
oUri.Parse("content://telephony/carriers")
oList.Initialize
oBrow.Initialize
Dim crsr As Cursor = cr.Query(oUri, Array As String( "_id", "name","apn","type" ), "", Null, "" )
For i = 0 To crsr.RowCount - 1
crsr.Position = i
Dim oApn As Apns
oApn.nId = crsr.GetLong( "_id" )
oApn.cName = crsr.GetString( "name" )
oApn.cApn = crsr.GetString( "apn" )
If oApn.cName.ToLowerCase = "claro" OR oApn.cName.ToLowerCase = "claro1" OR oApn.cName.ToLowerCase = "orange" OR oApn.cName.ToLowerCase = "claro2" Then
oList.Add( oApn )
oBrow.Add( oApn.cName )
End If
Next
nRes = InputList(oBrow, "Seleccione Apn", -1)
If nRes <> DialogResponse.CANCEL Then
oApn = oList.Get( nRes )
SetDefaultApn( oApn.nId )
End If
End Sub
Sub SeekApn( cApn As String ) As Boolean
Dim oUri As Uri
Dim oApn As Apns
oUri.Parse("content://telephony/carriers")
Dim crsr As Cursor = cr.Query(oUri, Array As String( "_id", "name","apn","type" ), "", Null, "" )
For i = 0 To crsr.RowCount - 1
crsr.Position = i
Dim oApn As Apns
oApn.nId = crsr.GetLong( "_id" )
oApn.cName = crsr.GetString( "name" )
oApn.cApn = crsr.GetString( "apn" )
If oApn.cName.ToLowerCase = cApn.ToLowerCase Then
Return True
End If
Next
Return False
End Sub
Sub SetDefaultApn( nId As Int )
Dim values As ContentValues
Dim uri1 As Uri : uri1.Parse("content://telephony/carriers/preferapn")
values.Initialize
values.PutInteger("apn_id", nId)
cr.Insert(uri1, values)
End Sub
Sub GetDefaultApn
Dim oUri As Uri : oUri.Parse("content://telephony/carriers/preferapn")
Dim crsr As Cursor = cr.Query(oUri, Array As String( "_id", "name","apn","type" ), "", Null, "" )
For i = 0 To crsr.RowCount - 1
crsr.Position = i
Dim cName As String = crsr.GetString( "name" )
Dim cApn As String = crsr.GetString( "apn" )
Next
Msgbox( cName & " " & cApn, ":: Lotenet ::")
End Sub
Sub PutApn( cName As String, cApn As String, cMcc As String, cMnc As String )
Dim values As ContentValues
Dim uri1 As Uri : uri1.Parse("content://telephony/carriers")
values.Initialize
values.PutString("name", cName )
values.PutString("apn" , cApn )
values.PutString("mcc" , cMcc )
values.PutString("mnc" , cMnc )
values.PutString("numeric", cMcc & cMnc )
cr.Insert(uri1, values)
End Sub