Android Question Problem with java inline code

mauro vicamini

Active Member
Licensed User
Longtime User
Hi everyone,
I'm doing a test application for testing automatic date time.
My problem is that when I try to compile the compiler gave me this error
B4X:
B4A version: 6.80
Parsing code.    (0.00s)
Compiling code.    (0.02s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Generating R file.    (0.03s)
Compiling generated Java code.    Error
javac 1.8.0_65
src\b4a\example\main.java:3: error: cannot find symbol
import android.provider.Settings.Global;
                                ^
  symbol:   class Global
  location: class Settings
Note: src\b4a\example\starter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
The code is the following one:
B4X:
#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

I attach the project.

Someone could give me some hint?

Thanks a lot for the attention.
 

Attachments

  • automaticdate.b4a.zip
    13.5 KB · Views: 124
Last edited:

JordiCP

Expert
Licensed User
Longtime User
From the IDE menu, go to: Tools->Configure Paths ->android.jar , to see at which one is pointing to (and change it to 18 if it is pointing to 14)
 
Upvote 0
Top