Android Question Second Activity Goes Background When FuseLocation Service Run

A Z M JANNAT UL KARIM

Member
Licensed User
Hi, I am checking for Location Periodically. I have multiple activity in my application. When I working on Second Activity, if the Location Service starts, it goes background of the Main Layout.

I am starting the Service from Main Activity as below ...

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    If FirstTime Then
        CreatePreferenceScreen
        StartService(GPSLocTrck)
    End If
End Sub

It starts the service through StartServiceAt function periodically. I am running the activity through AppCompat slide menu. Any help on how to run the service so that Second or Other Activity don't go Background. Thank You.
 

A Z M JANNAT UL KARIM

Member
Licensed User
Wow !!! Thanks A Lot. You are right. Just remodeling few codes sort out the problem. Thank you again ...

But one issue. Following code need to run from an Activity.

B4X:
Sub HandleLocationSettingsStatus(LocationSettingsStatus1 As LocationSettingsStatus)
    Select LocationSettingsStatus1.GetStatusCode
        Case LocationSettingsStatus1.StatusCodes.RESOLUTION_REQUIRED
            Log("RESOLUTION_REQUIRED")
            '    device settings do not meet the location request requirements
            '    a resolution dialog is available to enable the user to change the settings
            LocationSettingsStatus1.StartResolutionDialog("LocationSettingsResult1")
        Case LocationSettingsStatus1.StatusCodes.SETTINGS_CHANGE_UNAVAILABLE
            Log("SETTINGS_CHANGE_UNAVAILABLE")
            '    device settings do not meet the location request requirements
            '    a resolution dialog is not available to enable the user to change the settings
            Msgbox("Unable to listen for location updates, device does not meet the requirements.", "Problem")
            ' Activity.Finish
    End Select
End Sub

Now in log view it shows the following error

LocationSettingsResult StartResolutionForResult was not called from an Activity

I was using the following line to run it ...

CallSubDelayed2(Main, "HandleLocationSettingsStatus", LocationSettingsStatus1)

What should I do ?
 
Upvote 0
Top