#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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.
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")
testAutomaticDate
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub testAutomaticDate()
Dim java As JavaObject
Dim p As Phone
java.InitializeContext
If p.SdkVersion <= 16 Then
Dim result As Int =java.RunMethod("TimeZoneAutoOld",Null)
Select result
Case 1
Msgbox("Automatic old","time")
Case 0
Msgbox("Manual old","time")
End Select
Else
Dim result As Int =java.RunMethod("TimeZoneAuto",Null)
Select result
Case 1
Msgbox("Automatic","time")
Case 0
Msgbox("Manual","time")
End Select
End If
End Sub
#If java
import android.provider.Settings.Global;
import android.provider.Settings.System;
import android.provider.Settings.SettingNotFoundException;
public int DateTimeAuto(){
return android.provider.Settings.Global.getInt(getContentResolver(), android.provider.Settings.Global.AUTO_TIME, 0);
}
//For api 16 and below
public int DateTimeAutoOld(){
return android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.AUTO_TIME, 0);
}
public int TimeZoneAuto() {
return android.provider.Settings.Global.getInt(getContentResolver(), android.provider.Settings.Global.AUTO_TIME_ZONE, 0);
}
// For API 16 and below
public int TimeZoneAutoOld() {
return android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.AUTO_TIME_ZONE, 0);
}
#end if