To the developers under J2ME.
Is it possible to get a list of all available WiFi points in the moment in Java? Class IAPInfo gives me just a list of available network connections, where there are different internet and other connections, such as internet.mts.ru etc. and besides there is the connection 'Search for WLAN' (like so) and there are no access points themselves there. Already seen examples of a list of WiFi points in C + + for Symbian, but I'm writing in Java. I need a list of access points to define an exact position of mobile phone. I know about cellular communications and GPS, but I also need WiFi.
You can't get a list directly from J2ME.
A better idea is to use JSR 179's LocationProvider which will use any means at its disposal to provide you with a location reading (this may or may not include WIFI locating).
Related
How to get scan result from wifi for example every 3 seconds, without mWifimanager.startScan();
Google says :
startScan()
This method was deprecated in API level P. The ability for apps to trigger scan requests will be removed in a future release.
Notice for this API level i'm using
List<ScanResult> results = mWifiManager.getScanResults(); without calling startScan , the list contains the wifi AP's but it makes updated very very slow
Update to 12 January 2019 : https://issuetracker.google.com/issues/112688545
Google has now documented the limitations for startScan() function in Android P:
"We are further limiting the number of scans apps can request to improve network performance and improve battery life.
The WifiManager.startScan() usage is limited to:
- Each foreground app is restricted to 4 scans every 2 minutes.
- All background apps combined are restricted to one scan every 30 minutes."
Source:
https://issuetracker.google.com/issues/79906367
Edit 8-Aug-2018: Information has been added also here:
https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling
I think in API level P they're planning to move startScan() to a different class (WifiScanner) all together with some key differences.
See: https://android.googlesource.com/platform/frameworks/base/+/android-p-preview-1/wifi/java/android/net/wifi/WifiScanner.java
If there's an alternative solution to this, I'd love to hear it as well.
For now, I might just use startScan() until official docs are released.
startScan() is actually pretty buggy on P, as I raised Google Issue 79906367.
I don't think that WifiScanner is the replacement either, as that is marked as a SystemApi which means no access for Apps...
Hopefully we will hear soon, as RTT still means you need to scan for APs which support 802.11mc using ScanResult is80211mcResponder which you check before performing RTT Ranging on the AP.
StartScan() method is deprecated in Android P and new RTT protocol from 802.11mc standard has to be used with trilateration Algorithms.
https://android-developers.googleblog.com/2018/03/previewing-android-p.html
X,Y position of the AP should to be knonw for accurate positioning and the AP should support 802.11mc's Fine Time Measurement. IntelĀ® Wireless-AC 9260 support 802.11mc and several APs start supporting 802.11mc standard.
A couple of examples:
https://medium.com/#rafaelmiguel.ortega/android-p-first-taste-of-rtt-support-febefb679775
https://medium.com/#plinzen/perform-wifi-round-trip-time-measurements-with-android-p-9ffc5277ac6a
From WifiManager#EXTRA_RESULTS_UPDATED
Note: Apps holding android.Manifest.permission.NETWORK_SETTINGS permission are exempted from scan throttling.
Note: This is a system permission, regular apps can't use it without rooting and moving the app to the 'privileged' location or having it baked into a custom ROM.
I would guess the intention is to have developers/users use WifiRttManager instead for indoor location atleast [1].
Or rely on usual Google Play location services, which is an option in some use cases, but definitely not all. It's optimised for the average use case. No use case is the average use case.
Unfortunately with the way WifiRttManager calculates location it requires the wifi accesspoints to have 802.11mc. However you don't need to connect to these points.
Virtually 0 routers today have this standard. [2] [3] [4]
With 3 access points you can get location close to 1-2m accuracy.
Who knows if they'll place restrictions on this functionality as well though.
I'm not happy that this functionality is being taken away from users and developers - all it needs is a permission.
So it appears there will be a dark age for indoor location over the next few years until 802.11mc is popular.
Perhaps a workaround is to have devices you are connected to and ping them.
[1] https://developer.android.com/reference/android/net/wifi/rtt/WifiRttManager
[2] https://github.com/Plinzen/android-rttmanager-sample
Additional reading
[3] https://en.wikipedia.org/wiki/IEEE_802.11mc
[4] https://fit-iot.com/web/wifi-indoor-positioning/
I think google is planning to restrict application from scanning wifi.
This method was deprecated in API level 28. The ability for apps to
trigger scan requests will be removed in a future release.
Check the documentation here.
Q. What are your best practices in managing bluetooth connectivity?
I've read the android bluetooth guide & many bluetooth connectivity tutorials. Not helpful with encapsulation-design nor best practices.
When should I open/close the connection?
Is the "connection" with a single bluetooth device called a "socket" connection?
Can a single connection send data while listening? (...or between listening states).
I've never coded connectivity with external devices before. It took two weeks for me to wrap my head around the code that scans for near-by bluetooth devices and throw them into a ListView. Listeners, Broadcasts, and Adapters!
My project will be printing 1-40 receipts every 15 minutes on a bluetooth receipt printer. At the moment, security is not an issue. On the same connection, it will also be receiving data (sending & receiving simultaneously does not appear to be necessary but would be useful). I'm not yet sure how the devices are configured on this single dongle device but I would guess the devices are connected via USB controller to the dongle.
So far, I have 1 object to manage a single I/O connection. Staticly I open an activity to select a connection (to later save the label, mac, and pin in the database). Based on tutorials, I have "open", "listen", "send", and "close" methods. What confuses me is "how" to use these functions. Can I leave a connection open all day (10hrs) and use it every 3mins? Should I open/close the connection when sending or requesting data? Where would I detect the need to reconnect?
sorry for the short answer, but from my practice with the Bluetooth API, I have found that this video describe the things very good (totally personal opinion...)
Video 1
In addition this is useful when you do NOT have any previous experience
Tutorial
And as last check out this question in stackoverflow it has a bunch of good references and examples!!
Again sorry for the shortage, but I believe that if you check these out at least most of your questions and concerns will become answered!
:)
EDIT
So, let me be a bit more descriptive and share some of my experience.
I have written an App that communicates with BLE device that has 3 functions
double sided event driven button (push the button on phone -> event is fired to the device; push the button on the BLE device -> event is fired to the phone)
send request from phone -> BLE device answers with current battery percentage
continuously reading strength signal (as aprox. distance) between the phone and the BLE device
So far so good, now the things is that the basic approach is:
Search for BLE devices (bluetooth search or "discovery" of nearby bluetooth devices)
Here you will need android permissions!
Choose the device you want to connect to
To differ the devices (maybe there are a lot around you :) ) you can use BLE device's name or UUID or ... best - use the name ;)
After both devices connect to each other you can then start the Gatt communication. The approach with state machine is a little too much overkill for me. But anyway the communication is done through bytes (in my case...)
In one of the videos/resources there was something specific and VERY HELPFUL at least for me! To be honest I don't remember it exactly, but the idea was that before any communication it's RECOMMENDED to read/get all the options from the BLE device or something similar...
Maybe it was something like discoverOptions() or something like that
Great thing will be to know your device "communication codes" or at least I call them that way.
Check this link for example: Link
** Now you can see there are tables with the USEFUL INFO! E.g. if you want to read the battery level you navigate to this page and find that in order to read the battery, the service name is UUID XXXXX and you need to send 0x01 to the BLE device and it will "answer" to your call with some data which is again in bytes.
I really hope that this is somehow helpful!
PLEASE NOTE
This is strictly coming from my experience and there could be some mismatches or wrong terms, but that's how I personally see the things and because my project was long ago, I don't remember most of the things exactly.
IMPORTANT:
This is only a summery of STUCI's provided links above. He has since updated his answer and I have not updated/edited this summery. Topics in my summery are not explanatory but provided for reference and help in generating specific questions.
Original Post...
Thank you Stuci! Some of that was helpful:- some not. I thought it best to collect my thoughts and see what has been explained and if anything hasn't.
(I can't post this much in a comment tho, sorry)
PLEASE CALL ME ON ANYTHING THAT IS INCORRECT.
Video of Bluetooth LE
(Covers a bunch of random things)
While I "dont-like" videos of code:- I watched it because it was recommended ... and I am glad I did. While not very helpful it did introduce some concepts I was unaware of. Since I am targeting old android devices (v8+) the LE features are inconsequential.
Pushing Data: [Depending on the source feature-set], one does not need to continually pull data (ex. with a temperature sensor) but some devices can "push" it to the device on change. Seems to use the 'advertisement" design concept.
UUIDs define Services and/or Characteristics of the connected device.
Possibility to write configuration on (to) connected devices.
Characteristics which seem to be simply "settings" that can be assigned over bluetooth. Not sure if this (~19mins) applies to non-gatt connectoins but seems similar to the state-machine that controls
Advertisements which seem to be the "metadata" regarding the devices current state or config (~24mins). Again, not sure if this even applies to non LE Bluetooth.
Leaving Connections Open
Bluetooth connections can indeed remain open; starting at the point which the "startActivityForResult(...) method is successfully called.
Two basic things affect whether or not one would want to maintain an open connection:
Understand the power consumption.
Having the adapter active simply consumes additional power. If one can keep the adapter shut-off while it is not "absolutely-needed" will mearly save battery power.
Accidental disconnects are managed.
Other than leaving the connection continually connected, one could disconnect & reconnect regularly at specified intervals to ensure a connection is up.
In the thread(s) used for I/O, one could check for a disconnect and reconnect (possibly starting a new thread).
I/O Streams pr Connection
A single connection can indeed "have" simultaneous Input & Output streams. I
Since it was suggested, I re-read Android's Bluetooth Guide and under "managing a connection" (talking about a single socket) I noticed this...
Get the InputStream and OutputStream that handle transmissions through the socket, via getInputStream() and getOutputStream(), respectively.
Read and write data to the streams with read(byte[]) and write(byte[]).
...but continues with noting that read & write block each other. Something I still need to look further into. It seems like you cant I/O simultaneously on the same socket???
Max Connections
I also looked into the max connection issue Stuci added and found no documentation on the Android-side. It might exist, I cant find it. However, most people seem to agree that there is a limitation (that could be as low as 4) imposed by whatever hardware you are coding for.
Some notable links:
- How many devices we can pair via Bluetooth of BLE to Android?
- How many maximum device can we pair via Bluetooth to android device at a time?
- https://groups.google.com/forum/#!topic/android-developers/adeBD275u30
I am trying to create an app to find the exact location of IP address. I did some research on IP addresses and many more. But whenever I try to locate an IP address it provides the location of Internet Service Provider. I want to track the exact geolocation or long & lat of that place. So can anyone help me out to let me know how to find the geolocation of Dynamic IP address
The information upon which such a service might (hypothetically) be based is not available. Ergo, the ISP level information is about as good as you are likely to get for wired IP addresses.
#salocinix wrote:
"The exact position of an end-user's IP is only store at the ISP database and is normally not given away."
The second part is definitely true. They don't and shouldn't give away details about their customers' physical locations. There are obvious privacy concerns with doing that.
But it is quite possible that the ISP doesn't store the customer's physical location at all. Certainly, there is no need for them to store it in the form of longitude and latitude. Whether they need to store it depends on who owns the wires. In Australia for instance, many customers' ISPs don't own the wires that carry the traffic to the customers' dwelling. In that case, the ISP (in theory) only needs to know the billing address for the customer. And then there is the case of ISPs who sell internet connectivity for mobile devices ... where the physical location of a given IP address can change on a minute-by-minute basis.
... just asking because google maps shows the exact location of my PC on map how does it work
The PC is most likely geolocating itself via a combination of GPS and triangulation of local wireless base stations.
The exact position of an end-user's IP is only store at the ISP database and is normally not given away by the IS-provider. Try out the following link, you'll not achieve much more precision.
http://www.iplocation.net/index.php
I urge you to read the following thread on NANOG which was written by Fred Baker of Cisco, author of 50 network related RFC's.
Well, let me ask you you think 171.70.120.60 is. I'll give you a hint;
at this instant, there are 72 of us.
Here's another question. Whom would you suspect 171.71.241.89 is? At
this point in time, I am in Barcelona; if I were home, that would be my
address as you would see it, but my address as I would see it would be
in 10.32.244.216/29. There might be several hundred people you would
see using 171.71.241.89;
Geolocating is gimmicky at best.
I'm building a location based application and I would like to avoid from this kind of location: "Tel Aviv, Tel Aviv, Israel" which is very not accurate.
I use the following condition before using a location:
if(!(this.location == null || this.location.getAccuracy() > 700))
// use the location
But I keep getting this locations (Tel Aviv, Tel Aviv, Israel), and Tel Aviv is not small enough to pass this condition.
I'm missing something? What's wrong?
You haven't specified a couple of parameters involved but I'll give it a try.
The exact Location parameters depend on the source of that particular Location, i.e. how it was obtained and using what geolocation source(s). For example:
If you use GPS, the Location will have reliable accuracy values.
If you use cellular network radio stations (BTS), the accuracy you'll receive will be limited to the database of BTS around the world, their location and range.
If you use Wi-Fi networks and their reported signal strength, the accuracy will depend on the quality of the database of the Wi-Fi networks. Unfortunately such databases are not cheap to maintain and create. For example Google buys such databases and uses Google Street View cars for scanning such networks.
If you use localization based on public IP address, your accuracy will be limited to a town, because that is the most accurate information contained in IANA IP address space registry. Also, it can be fooled by using a proxy servers.
The accuracy you'll receive from a location service represents a distance (in meters) from the reported location in which the device is likely to be in the moment the location was obtained.
So (if I understand your question correctly), I presume your using a low-accuracy method of obtaining current device location. You simply must switch to a source of Location with greater accuracy.
Please also note that the location-acquiring method (i.e. the service used to find the location as described above) used by the location service might actually not be able to provide accuracy for returned Location. To understand what I mean by that consider a following scenario and their two outcomes - note that they both come from the same locating method based on Wi-Fi networks:
You are in range of several Wi-Fi networks. You ask the location service about device location. All Wi-Fi networks in range happen to be in location service DB. The location service is thus able to get your location with decent accuracy.
You are in range of several Wi-Fi networks. However, none of them happens to be well known to location service in that their origin (town) is known, but their exact location and range is not known. In that case the location service is able to tell you which country/town you are in, but has no idea on your precise location. In turn, location service can give you a location with no accuracy.
You must make yourself prepared for such an occasion by testing if the accuracy is available at all. You can do this by issuing Location.hasAccuracy(). If the returned value is false, you can't call Location.getAccuracy() (actually you can, but beware - it'll return 0!). So, your condition should be more like:
if (this.location != null && this.location.hasAccuracy() && this.location.getAccuracy() < 700) {
// do something
}
For getting Geographical Position of a user we have so many API's can any one tell me what is the concept behind this? How these api's can detect the geographical co ordinates of a user.
Please Explain
Thanks and Regards,
Sunny.
This depends entirely upon the API.
Some APIs are dependent on a piece of hardware (such as a smartphone) that utilizes an inbuilt GPS.
Other APIs attempt to use WiFi and/or IP data to attempt a crude calculation for your location. Google's MyLocation feature is an example of this, it uses information gathered by your browser to estimate your location. Here's a link to an article discussing Google's use of WiFi/IP to calculate users positions:
Google MyLocation
Others such as Google, Bing, or ESRI map based APIs allow you to query their maps to receive coordinate information about a specific address that the user inputs. If you already know users are going to access your application from a relatively small geographic area, you can submit the query on their behalf and use it to create a map based on this area (ie: a city, college campus, etc...), or to obtain a set of geographic coordinates when all you have are the addresses (ie: a list of restaurants, apartments, etc...).
Any particular API that you are talking about?
As far as I know, there are 2 ways in general
GPS-enabled devices: So the device itself that know its own geolocation through it's GPS system
Through who you are connected to: a) If you are mobile device, they can pinpoint your location through figuring out the towers you are connected to, or b) If you are on an internet / wi-fi connection, it can be figured out from there.
http://www.ehow.com/how-does_4965061_gps-work-mobile-phones.html
or
How does GPS in a mobile phone work exactly?