Skip to content

Instantly share code, notes, and snippets.

@iosharry
iosharry / iOS13StatusBarExample.swift
Created September 18, 2019 14:31
iOS13 StatusBar Crash Issue
private var statusBarView: UIView?
if #available(iOS 13.0, *) {
let tag = 38482458385
if let statusBar = UIApplication.shared.keyWindow?.viewWithTag(tag) {
statusBarView = statusBar
} else {
let statusBar = UIView(frame: UIApplication.shared.statusBarFrame)
statusBar.tag = tag
UIApplication.shared.keyWindow?.addSubview(statusBar)
@yoni-g
yoni-g / closeAppElegantly.swift
Last active March 30, 2023 02:08
How to exit an iOS app without it looking like a crash? - Swift
func showMessageResetApp(){
let exitAppAlert = UIAlertController(title: "Restart is needed",
message: "We need to restart the app on your first login to the app.\n Please reopen the app after this.",
preferredStyle: .alert)
let resetApp = UIAlertAction(title: "Close Now", style: .destructive) {
(alert) -> Void in
// home button pressed programmatically - to thorw app to background
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
// terminaing app in background
@emil2k
emil2k / Connectivity.java
Last active December 22, 2023 06:03
Android utility class for checking device's network connectivity and speed.
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions: