Loading...
Home
  • Tech Blogs
  • Videos
  • Conferences
    • Droidcon News
    • Upcoming Conferences
    • Become a Partner
    • Past Events
    • Keep Me Informed
    • Diversity Scholarships
  • Community
    • droidcon Team
    • How to Hold a Droidcon
  • Android Careers
Sign In

Global CSS

 

Android WiFi Scanning Frustrations

How wifi scanning has changed with the release of new versions of Android and how Google continues to limit developer opportunities

 

 
Elvina Sh
Marketing associate at Navigine.com — Integrated software platform for precise positioning.
Published: September 10, 2020
Tweet
Share
 

Image by Gaspart from Dribbble

 

Hi there! In the Navigine team, we’ve been providing indoor and outdoor positioning mobile technologies that enable advanced indoor navigation and proximity solutions for eight years.

Today we want to tell you more about WiFi scanning on different versions of Android devices and the restrictions you could meet during the development process. In some of our previous articles, we mentioned a few important details of working with a WiFi scan and various restrictions concerning it, but now we decided to combine all this in one place and write a full article describing all the nuances.

Since restrictions and changes are strongly tied to Android versions, we will divide the article into subsections regarding these versions. However, it is also worth noting that we will only consider the versions of Android that are actively used now and will not consider those versions that have long been out of circulation. So let’s start!

 

Android Oreo and earlier

A couple of years ago, Google still did not pay much attention to working with wifi and did not introduce any restrictions and everything worked the same way as it did many years before. Therefore, the wifi scanning worked without any restrictions and it was possible to scan continuously. Here is the code snippet below which shows how wifi scanning works.

 

 

You create the Broadcast Receiver, override its onReceive method, register your receiver with related intent filter and then call startScan on your wifi manager. As you can see, very simple and straightforward code. And it worked just as easily as it looks and without any difficulties.

Let’s make a small digression by mentioning that around the same time Google began to severely limit developers in their capabilities. For example, they limited the ability of services to work in the background, and much more. However, at that moment there were no restrictions on working with WiFi, and people working with this functionality could keep calm. But the worst happened later…

 

Android Pie and Android 10

At the release of the version of Android 9, Google presented a surprise to all developers. The wifi scan was cropped as much as possible. Now you can start the scan only four times every 120 seconds. If you try to start the scan more times, then all your attempts will be throttled. And then everyone who did not have time to read the documentation about the new changes faced difficulties because their scan worked a couple of times and then disappeared for two minutes.

 

 

To put it mildly, this is very unpleasant from the point of view of developers. 
Now we had to add if-else construction for scanning evenly during this time. Here is the code snippet above which shows, how we used it in our solution. In total, nothing smart, the scan process works the same way, just now I had to add more checks so that everything worked with a certain pause so as not to catch throttling.

But we did not mention here the main thing that happened with Android 10, Google made deprecated WiFi scanning. At the same time, no new solution appeared and there were no alternatives. We had to wait for a new version of Android.

 

Android 11

And this new version brought a new solution for WiFi scanning. However, it has not yet been documented, while it will only work in the new version of Android, which means you will have to add even more if-elseconstructions. Here is the code snippet which shows the methods for the new WiFi scanning process and the explanation of how it should work.

 

 

Now you need to register the scan results callback instead of start scan, pass there new ScanResultsCallback class element. You should override its onScanResultsAvailable() method and there you can call the get scan results method (provided in the code snippet). And also there is a method for unregistering scan callback.

Unfortunately, we were unable to test this solution in the absence of a new version of Android and cannot say whether it works as well, whether the old restrictions apply to it, and how much more convenient it is.

 

Summary

As you can see, Google more and more wants the developers’ code to be replenished with if-else constructions. It’s safe to say that they are trying to limit developers as much as possible from being able to scan wifi devices. But it’s worth noting, there are ways to bypass this, at least during testing, for example, on the Android 10, you can turn off wifi scan throttling. Well, let’s hope that the new scan will be much more convenient and less limited.

 

Thanks to Andy Dyer. 

 

Tags: Android,Android App Development,Programming,Technology,AndroidDev

 

View original article at: 


 

Originally published: September 09, 2020

Android News
Getting… your BottomSheetScaffold working on Jetpack Compose Beta 03
Getting… your BottomSheetScaffold working on Jetpack Compose Beta 03

By Carlos Mota

It’s Monday, no releases this week, and… there’s a new version of Jetpack Compose — beta 03—available. What a perfect time to just increment 02 to 03 and see what’s new. The API is (almost) final so after updating from alpha to beta there weren’t any big changes to do. However, and remember that’s still in development, there’s always something that I need to update. 

By ProAndroidDev -
Android News
Noisy Code 🗣 With Kotlin Scopes
Noisy Code 🗣 With Kotlin Scopes

By Chetan Gupta

Scopes make your code more readable? think again... You are going to encounter these scope functions namely let, run, apply, also, within every Kotlin codebase, along with all the mischievous ways developers exploit their usage from the way they were intended for. Let see how popular opinion on those ends up just as a code noise.

By ProAndroidDev -
Android News
Improving Android DataBinding with Bindables library
Improving Android DataBinding with Bindables library

By Jaewoong Eum

DataBinding is one of the most important factors for MVVM architecture. The basic concept of DataBinding is to link the view and view model via observer patterns, properties, event callbacks, etc. Linking and automating communication between the view via the bound properties or something in the view model has a lot of benefits in the MVVM architecture concept.

By ProAndroidDev -
Android News
KMM QuickStart Guide
KMM QuickStart Guide

By Mayank Kharbanda

Kotlin Multiplatform (KMP) is a code-sharing technology that allows us to use the same code for different platforms whether it’s JVM, Android, iOS, watchOS, tvOS, Web, Desktop, or WebAssembly. In this article, we will use Kotlin Multiplatform Mobile (KMM) which is a subset of KMP with the focus on providing better tooling and support for sharing code on mobile platforms i.e. Android and iOS.

By ProAndroidDev -
droidcon News

Tech Showcases,

Developer Resources &

Partners

/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/home-details/EmployerBrandingHeader
EmployerBrandingHeader
https://jobs.droidcon.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/jobs-droidcon/jobs.droidcon.com
jobs.droidcon.com

Latest Android Jobs

http://www.kotlinweekly.net/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/kotlin-weekly/Kotlin Weekly
Kotlin Weekly

Your weekly dose of Kotlin

https://proandroiddev.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/pad/ProAndroidDev
ProAndroidDev

Android Tech Blogs, Case Studies and Step-by-Step Coding

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
Zalando

Meet one of Berlin's top employers

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
Academy for App Success

Google Play resources tailored for the global droidcon community

Follow us

Team droidcon

Get in touch with us

Write us an Email

 

 

Quicklinks

> Code of Conduct

> Terms and Conditions

> How to hold a conference

> FAQs

> Imprint

Droidcon is a registered trademark of Mobile Seasons GmbH Copyright © 2020. All rights reserved.

powered by Breakpoint One