I've an app that uses the LocationManager in Android and i'm tryng to get the current time provided by gps in millis.
I noticed in my database a row with a wrong timestamp.
There's others that are always corrected, for example:
1477050084629: Correct time provided
6406148: Incorrect time provided
The incorrect time is provided by using a device Samsung SM-J105B (Galaxy J1 Mini Dual Chip).
I didn't find topics related a problem like this, only problems when the time is different by hours or days.
In my case the timestamp return a number of small quantity of digits.
I think the problem would be generated by device, see this topic:
https://support.strava.com/hc/en-us/articles/216515918-My-Activity-has-the-wrong-date-
I'm assuming a bigint column. Ask yourself is one bit not set on a binary number? Look at the code that uses that column then look specifically how the value is passed in code is it serialized when it's passed to your code? Check if the value is converted to and from human readable timestamps.
Related
This question already has answers here:
What is a UUID?
(8 answers)
Closed last month.
ua:fa95ebdb-6da9-498c-aabb-77c7baaa28d3
When I woke up this morning, this "code" was the last text copied to my phone (Samsung, Android version 12), of course it was not me who copied this string, and I spent the night alone. I saw this when opening the GBoard keyboard, which offered to paste it. I didn't enable clipboard with this keyboard, so it was less than an hour before I woke up.
At first I thought it was me accidentally writing this text while sleeping (my phone is next to me all night, not turned off). But looking closer, I saw that it is a hex code. While searching on the net, I saw that ua can mean "user agent" but impossible to find what this hexadecimal string means...
Does anyone know this kind of string? Or would have any idea what could have happened to cause this to end up being copied to my phone? I admit it scares me...
The format of this string is called "UUID" (universally unique identifier), or "GUID" (globally ...) in some places.
It represents a series of 128 bits which are usually chosen at random when a unique ID for anything is needed.
The collision probability on 128 random bits is so low that they are considered unique (or more precisely: unique enough) even without a central coordinating instance that guarantees global uniqueness.
That being said - if "ua:" stands for "user agent" in this case, then it seems to be a string identifying your browser, and it might have gotten into your clipboard from a badly programmed tracking script on some website you visited.
This looks like an app's internal ID (GUID) to identify an entity. Within the context of the app in question,n copy and pasting something will result in an entity with that ID being copied. But if you paste it externally to the app, you will see the entity's ID. This is a common technique for app development.
I am using TimeZone class to get the time zone in SHORT format like "PST", "EST" etc. using TimeZone.getDefault().getDisplayName(false, TimeZone.SHORT, Locale.getDefault())
For some devices this piece of code is returning "PST" etc but some of the devices its returning "GMT+007" value. Anybody has an idea what can be the change I make to make it consistent to "PST" format.
The short name is a part of the time zone database. It seems that some devices are shipping time zone databases that doesn't include this information, or whose libraries ignore it.
To make this consistent I would include a mapping that maps from the long names to the short names. But then you would have to maintain that yourself, and you also need to get the long name (like "US/Hawaii") for each timezone, I don't know if that is possible for you, it depends on the use case.
Please also be aware that the short time zone names are ambiguous, there are many time zones called EST for example.
I want to validate phone number.
Phone Number = countryCode+areaCode+PhoneNumber.
I want to know what is the standard minimum and maximum length of Phone Number so i could validate it.
-thanks
Try this regex:
^[+]?[0-9]{10,13}$
Or this:
PhoneNumberUtils.isGlobalPhoneNumber("+912012185234");
It would depend on if you are accepting any country code or are looking for specific country code/s.
Then how many digits you are expecting for area code and then the actual phone number and whether these are being fetched as separate variables or one string.
So after answering these question. You can use (test your code) regex (learn how to use it), (and as #Basil has suggested), but vary the length (and possibly digits, if there are limited country codes) accordingly.
Here is a good answer to using regex in android.
This question is not specific to Android but I have included the tag.
I need to be able to store phone numbers in some sort of standard form (ideally a string) where equality can be tested/evaluated quickly (hence a string would be ideal)
I found some answers already, the best ones pointed to http://developer.android.com/reference/android/telephony/PhoneNumberUtils.html (I'm fine with using a library to do it for me)
BUT this isn't really good enough, I've tried a variety of format numbers, learnt about the Editable factory to use some of the static methods in that class, but they don't seem to return the form I was expecting.
I was expecting something like a phone-number-hash, that two inputs representing the same number would yield the same in this "standard form" and that one could dial this standard form and be fine. I thought that all the various +s and whatnot would be short-hands for this standard form.
I'm not sure if such a thing exists now.
I understand that some things mean "current area" (or country) which is why land-lines can ommit area codes, I expected a function that would return the format for the current location (but this doesn't apply to mobiles, if it were a land line to prepend the area code for example, this would be (closer) to the "standard form" I keep assuming exists)
I am pretty sure that some full-form for phone numbers exists, thinking about how the telephone system works (which I infer I admit) there ought to be a form that identifies a number uniquely across the whole planet, and when this is not the case (such as local calls from land-lines without area codes) it is an optimisation.
So I have two questions:
How can I "expand" a phone number to a unique string for that number, such that any alternate forms of writing that number (with spaces, an 0 or +44....) "expand" to this unique number?
Are there any ISO(/IEC?) (what's the O stand for?) standard documents with drafts open to the public? I've read the Wikipedia page (ages ago, I've spent so many hours wiki-browsing, and opened hundreds of tabs) but it covers history, or some information on formatting), I'd like to know more about the thing I've taken for granted now for some 8 years or so.
Additionally, why is Windows Phone 8 a tag? To make the 12 proud Lumina owners not feel left out? (It was suggested as a tag!)
Addendum
Unfortunately Any API in android to normalize phone number there are no solutions there (this includes libphonenumber) and my quest to find out has lead to some interesting reads:
http://en.wikipedia.org/wiki/Panel_switch
http://en.wikipedia.org/wiki/Nonblocking_minimal_spanning_switch
http://en.wikipedia.org/wiki/Telephone_exchange
and I still cannot conclude there isn't some "full form" for numbers.
I dare not create a solution that simply swaps +44 for an 0 and such.
After reading your question, I was reminded of Google's library called libphonenumber. Its Google's common library for parsing, formatting, storing and validating international phone numbers. It does the following things ( some of which seem what you might be able to use):
Parsing/formatting/validating phone numbers for all countries/regions
of the world.
getNumberType - gets the type of the number based on
the number itself; able to distinguish Fixed-line, Mobile, Toll-free,
Premium Rate, Shared Cost, VoIP and Personal Numbers (whenever
feasible).
isNumberMatch - gets a confidence level on whether two
numbers could be the same.
isPossibleNumber - quickly guessing whether a number is a possible
phonenumber by using only the length information, much faster than a
full validation.
isValidNumber - full validation of a phone number
for a region using length and prefix information.
AsYouTypeFormatter - formats phone numbers on-the-fly when users enter each digit.
PhoneNumberOfflineGeocoder - provides geographical information related to a phone number.
As far as international format of phone number is concerned, E.164 format is an recommended by International Telecommunication Union. It defines a numbering plan for the world-wide public switched telephone network and is a general format for international telephone numbers ( usually stats with + followed by country code, Area code and the number).
Using the above library, validity of all the phone numbers can be checked if you mention the international code along with the phone number ( example 1 for US & Canada). If you don't have the code but you know the country's name for which you want to check the number, then also you can validate. You can also convert all the valid numbers of 1 standard E.164 format using this library. You can also 'expand' a number in Local National format of that particular country. You can save it as String as well. Although it does use PhoneNumberUtils that you mentioned in your question.
I am not sure if this is what you are looking for but I hope this information helps you.
I'm writing an Android app that reads and parses NMEA sentences from GPS receiver and using a Nexus S phone for tests.
I'm getting GPGGA, GPGSV, GPGSA and GPRMC sentences that are pretty common and very well documented, but in addition, I'm getting next sentences and I'cant find any info about them:
PGLOR, GNGSA, QZGSA
Where I can find some docs about those sentences format?
The $GN-prefix is usually used when the sentence is formed using several satellite constellations (so far usually Glonass and GPS are the viable options). The $QZ-prefix is a little more unclear but I assume that it is for the Japanese QZSS-satellite constellation.
The rest of the sentence after the prefix is standard NMEA 0183 and contains what the normal GSA-sentence would contain.
The $PGLOR is probably used to produce information and / or configure the locationing chip. Or something similarly uninteresting.
What's really interesting is that Nexus S seems to have a Multi GNSS locationing chip.
Further information here
I recently wrote an app that parsed the GPGGA NMEA strings, my advice is parse what you need, and leave the rest. Generally you don't need all formats, only specific ones.
The first two characters typically define the type of device sending the message, with the last three being the type of message. $GNGSA and $QZGSA should be reporting the same or similar data as $GPGSA, which would be satellite data, including dilution of precision.
I don't know which device these come from, but GN is mentioned here: http://macrogroup.ru/content/data/store/images/f_1072_5353_1.pdf
Regarding $PGLOR... I'm not sure. Perhaps if you could post what chipset is used internally, its documentation could be consulted.