milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

Hospital

Details
Written by: Stanko Milosev
Category: Downloads
Published: 19 March 2012
Last Updated: 30 November -0001
Hits: 14935

Application, on Serbian, made for the hospital in Novi Sad.

Instalation with MSDE you can find here.

Instalation without MSDE you can find here.

WebSphere

Details
Written by: Stanko Milosev
Category: Downloads
Published: 17 March 2012
Last Updated: 19 March 2012
Hits: 15069

Example of client application for IBM WebSphere MQ.

Exe and source code (Delphi 2009)

Get the last known location with LocationManager

Details
Written by: Stanko Milosev
Category: Android
Published: 30 November 2025
Last Updated: 09 December 2025
Hits: 55
  • kotlin
Hier I gave one example of getting the last known location with FusedLocationProviderClient

Now here is example with LocationManager:

Example with trailing lambdas:

val locationManager = getSystemService(LOCATION_SERVICE) as LocationManager
locationManager.requestLocationUpdates(
	LocationManager.GPS_PROVIDER,
	1000L,
	0f
) { location ->
	logger.log("\nLat: " + location.latitude.toString()
			+ "\nLon: " + location.longitude.toString()
			+ "\nAltitude" + location.altitude.toString())
}
but in order to be able to stop requests, declare lamba like function type:
private lateinit var gpsListener: LocationListener
...
gpsListener = LocationListener { location ->
	logger.log(
				"\nLat: " + location.latitude.toString()
				+ "\nLon: " + location.longitude.toString()
				+ "\nAltitude" + location.altitude.toString()
	)
}

locationManager.requestLocationUpdates(
	LocationManager.GPS_PROVIDER,
	1000L,
	0f,
	gpsListener
)
Stop it like this:
locationManager.removeUpdates(gpsListener)
Example download from here.

Get the last known location with FusedLocationProviderClient

Details
Written by: Stanko Milosev
Category: Android
Published: 29 November 2025
Last Updated: 30 November 2025
Hits: 105
  • kotlin
In "\app\build.gradle.kts"I have added:
implementation("com.google.android.gms:play-services-location:21.3.0")
in "\app\src\main\AndroidManifest.xml"
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Shortly, I am using this code to receive last known location
var locationRequest: LocationRequest
val localInterval: Long = 0
locationRequest = LocationRequest.Builder(
	Priority.PRIORITY_HIGH_ACCURACY, TimeUnit.SECONDS.toMillis(localInterval)
).apply {
	setGranularity(Granularity.GRANULARITY_PERMISSION_LEVEL)
	setDurationMillis(TimeUnit.MINUTES.toMillis(Long.MAX_VALUE))
	setWaitForAccurateLocation(true)
	setMaxUpdates(Int.MAX_VALUE)
	setIntervalMillis(TimeUnit.SECONDS.toMillis(localInterval))
	setMinUpdateIntervalMillis(TimeUnit.SECONDS.toMillis(localInterval))
	setMinUpdateDistanceMeters(0F)
}.build()
val locationCallback = object : LocationCallback() {
	override fun onLocationResult(locationResultLocal: LocationResult) {
		logger.log("\nLat: " + locationResultLocal.lastLocation?.latitude.toString()
				+ "\nLon: " + locationResultLocal.lastLocation?.longitude.toString()
				+ "\nAltitude" + locationResultLocal.lastLocation?.altitude.toString())
	}
}

val fusedLocationClient = LocationServices.getFusedLocationProviderClient(myActivity)
fusedLocationClient.requestLocationUpdates(
	locationRequest, locationCallback, Looper.getMainLooper()
)
Notice line:
setMinUpdateIntervalMillis(TimeUnit.SECONDS.toMillis(localInterval))
With setMinUpdateIntervalMillis I am reciving location as soon as possible, constantly, without stopping.

To stop location updates use this code:

fusedLocationClient.removeLocationUpdates(locationCallback)
My class for starting / stoping location updates looks like this:
package com.example.testsandbox

import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager
import android.os.Looper
import androidx.core.app.ActivityCompat
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.Granularity
import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.LocationResult
import com.google.android.gms.location.LocationServices
import com.google.android.gms.location.Priority
import java.util.concurrent.TimeUnit

class MyFusedLocationClient(var logger: ILogger) {
    private lateinit var fusedLocationClient: FusedLocationProviderClient
    lateinit var myActivity: Activity

    var locationCallback = object : LocationCallback() {
        override fun onLocationResult(locationResultLocal: LocationResult) {
            logger.log("\nLat: " + locationResultLocal.lastLocation?.latitude.toString()
                    + "\nLon: " + locationResultLocal.lastLocation?.longitude.toString()
                    + "\nAltitude" + locationResultLocal.lastLocation?.altitude.toString())
        }
    }

    fun startLocationUpdates() {
        myRequestLocationUpdates(myActivity)
    }

    fun stopLocationUpdates() {
        fusedLocationClient.removeLocationUpdates(locationCallback)
    }

    private fun myRequestLocationUpdates(myActivity: Activity) {

        if (ActivityCompat.checkSelfPermission(
                myActivity,
                Manifest.permission.ACCESS_FINE_LOCATION
            ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
                myActivity,
                Manifest.permission.ACCESS_COARSE_LOCATION
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            ActivityCompat.requestPermissions(
                myActivity,
                arrayOf(Manifest.permission.ACCESS_FINE_LOCATION),
                REQUEST_LOCATION_PERMISSION
            )
        }

        var locationRequest: LocationRequest
        val localInterval: Long = 0
        locationRequest = LocationRequest.Builder(
            Priority.PRIORITY_HIGH_ACCURACY, TimeUnit.SECONDS.toMillis(localInterval)
        ).apply {
            setGranularity(Granularity.GRANULARITY_PERMISSION_LEVEL)
            setDurationMillis(TimeUnit.MINUTES.toMillis(Long.MAX_VALUE))
            setWaitForAccurateLocation(true)
            setMaxUpdates(Int.MAX_VALUE)
            setIntervalMillis(TimeUnit.SECONDS.toMillis(localInterval))
            setMinUpdateIntervalMillis(TimeUnit.SECONDS.toMillis(localInterval))
            setMinUpdateDistanceMeters(0F)
        }.build()

        fusedLocationClient = LocationServices.getFusedLocationProviderClient(myActivity)
        fusedLocationClient.requestLocationUpdates(
            locationRequest, locationCallback, Looper.getMainLooper()
        )
    }

    companion object {
        const val REQUEST_LOCATION_PERMISSION = 123
    }

}
In activty use it like this:
val myFusedLocationClient = MyFusedLocationClient(logger)
myFusedLocationClient.myActivity = this
...
myFusedLocationClient.startLocationUpdates()
...
myFusedLocationClient.stopLocationUpdates()
Full example downlaod from here.
  1. Reloading a KML Layer in Google Maps in a Loop
  2. Remove KmlLayer from the Map to avoid OutOfMemory
  3. Load KML in Google Maps
  4. Simple Google Maps example

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 139 of 166

  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143