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

WebSphere

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

Example of client application for IBM WebSphere MQ.

Exe and source code (Delphi 2009)

OutOfMemoryError fix when loading KML

Details
Written by: Stanko Milosev
Category: Android
Published: 03 November 2025
Last Updated: 03 November 2025
Hits: 4
  • kotlin
Here I gave one example for loading KML in Google maps. Problem with it, is when I constantly load KML which is huge, since I want to display KML in real time, in some moment I will receive "OutOfMemoryError", this is one fix which is working:
var previousLayer: KmlLayer? = null

while(true) {
	previousLayer?.removeLayerFromMap()
	map.clear()
	val inputStream = FileInputStream(tempFile)
	val layer = KmlLayer(map, inputStream, activity)
	layer.addLayerToMap()
	inputStream.close()
	delay(10_000)
	previousLayer = layer
}
Line:
delay(10_000)
Is maybe most important, since it seems that garbage collection need some time to release memory.

Load KML in Google Maps

Details
Written by: Stanko Milosev
Category: Android
Published: 02 November 2025
Last Updated: 03 November 2025
Hits: 14
  • kotlin
Here I gave simple example of loading google maps in android app. Now I want to load KML file which is on my web site.

First I will add a button for load KML, in order to have clear example, so my layout looks like:

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <Button
        android:id="@+id/btnLoadKml"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Load KML"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:layout_marginBottom="32dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

In gradle "\GoogleMapsTestSandBox\app\build.gradle.kts" add dependency:
implementation("com.google.maps.android:android-maps-utils:3.19.0")
Now, setup view binding as I already explained here, MainActivity I will inherit from OnMapReadyCallback, so now it looks like:
package com.milosev.googlemapstestsandbox

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng
import com.milosev.googlemapstestsandbox.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity(), OnMapReadyCallback {

    private lateinit var binding: ActivityMainBinding
    private lateinit var map: GoogleMap

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        val mapFragment = supportFragmentManager
            .findFragmentById(R.id.map) as SupportMapFragment
        mapFragment.getMapAsync(this)

        binding.btnLoadKml.setOnClickListener {
        }
    }

    override fun onMapReady(googleMap: GoogleMap) {
        map = googleMap

        val tunis = LatLng(36.8065, 10.1815)
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(tunis, 8f))
    }
}
setOnClickListener is empty, here I will add:
val loadKml = LoadKml()
loadKml.execute(this, map)
Since my KML is too big, I had to extend timeouts, and first I am saving in into temp file, so class LoadKml will look like this:
package com.milosev.googlemapstestsandbox

import android.content.Context
import android.widget.Toast
import com.google.android.gms.maps.GoogleMap
import com.google.maps.android.data.kml.KmlLayer
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import java.io.FileInputStream
import java.net.URL

class LoadKml {
    fun execute(activity: Context, map: GoogleMap) {

        CoroutineScope(Dispatchers.IO).launch {
            try {
                val url =
                    URL("https://www.milosev.com/gallery/allWithPics/travelBuddies/tunis/kml/kml.kml")
                val connection = url.openConnection()
                connection.connectTimeout = 15000
                connection.readTimeout = 60000

                val tempFile = File(activity.cacheDir, "temp.kml")
                connection.getInputStream().use { input ->
                    tempFile.outputStream().use { output ->
                        input.copyTo(output)
                    }
                }

                withContext(Dispatchers.Main) {
                    val layer = KmlLayer(map, FileInputStream(tempFile), activity)
                    layer.addLayerToMap()
                    Toast.makeText(activity, "KML Loaded", Toast.LENGTH_LONG).show()
                }
            } catch (e: Exception) {
                withContext(Dispatchers.Main) {
                    Toast.makeText(activity, "Error: ${e.message}", Toast.LENGTH_LONG).show()
                }
            }
        }

    }
}
Example download from here.

Simple Google Maps example

Details
Written by: Stanko Milosev
Category: Android
Published: 02 November 2025
Last Updated: 02 November 2025
Hits: 9
  • kotlin
Here is one simplest possible example of google maps.

First start new "Empty Views Activity" like I already explained here

In "\GoogleMapsTestSandBox\app\build.gradle.kts" I have added "com.google.android.gms:play-services-maps:19.2.0", so my dependencies looks like

dependencies {
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.material)
    implementation(libs.androidx.activity)
    implementation(libs.androidx.constraintlayout)
    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)

    implementation("com.google.android.gms:play-services-maps:19.2.0")
}
Since I don't want to make google maps key public, I will add "secrets" file. To do it, first I wil add id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") version "2.0.1" plugin in gradle "\GoogleMapsTestSandBox\app\build.gradle.kts":
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") version "2.0.1"
}
Before I sync my gradle, I need to add two files local.defaults.properties and secrets.properties.

local.defaults.properties:

MAPS_API_KEY=DEFAULT_API_KEY
secrets.properties:
sdk.dir=C\:\\Users\\smilosev\\AppData\\Local\\Android\\Sdk
MAPS_API_KEY=myMapsApiKey;
Now in "\GoogleMapsTestSandBox\app\src\main\AndroidManifest.xml" add:
<meta-data
	android:name="com.google.android.geo.API_KEY"
	android:value="${MAPS_API_KEY}" />
Since in this example I just want to display google maps my "\GoogleMapsTestSandBox\app\src\main\res\layout\activity_main.xml" will look like:
<fragment
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
For this, simplest example my "\GoogleMapsTestSandBox\app\src\main\java\com\milosev\googlemapstestsandbox\MainActivity.kt" will look like:
package com.milosev.googlemapstestsandbox

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
    }
}
Example download from here.
  1. Receiver as separate class
  2. Foreground service as a separate process example
  3. Upload images from Android Kotlin to Web Api .NET Core - third Example
  4. Upload images from Android Kotlin to Web Api .NET Core - second 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 165

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