Localizing Persons name in Android App for different locales - android

In some locales, a person's full name is written out with last name (family name, surname) then first name (personal name, given name), instead of the more common first name then last name order.Is there any API in Android which can take care of this name ordering for my app depending on the locale of the phone.

I'm afraid, there's no API for that. I've been looking fot it for a while and all that i know is what #Shervin shared.
Currently:
You can try to manage that all yourself, by getting title, name, second name and last name from user. In english it's easy to order it correctly and concatenate it with space. Unfortunately - not every language use spaces.
Research:
CLDR is project providing any locale-specific data (for example in ICU), but order of name and family name is not there.
Possible solution:
Most of solutions out there can be summed up to:
If designing a form or database that will accept names from people
with a variety of backgrounds, you should ask yourself whether you
really need to have separate fields for given name and family name.
Sometimes you may opt for separate fields because you want to be able
to use part of the name to address the person directly, or refer to
them. For example, when Google+ refers to "Richard's contacts". Or
perhaps it's because you want to send them emails with their name at
the top. Note that not only may you have problems due to name syntax
here, but you also have to account for varying expectations around the
world with regards to formality (not everyone is happy for a stranger
to call them by their given name). It may be better to ask separately,
when setting up a profile for example, how that person would like you
to address them.
http://www.w3.org/International/questions/qa-personal-names#fielddesign
So you must choose if you need to ask your user separately for first name and last name (should be usefull in sorting), but even then - you need to know how they name should be displayed.
Mostly you'll see form that asks users to provide: First name, Last name and Displayed name. Check here (fourth heading) for explanation.

Related

How do I retrieve user's name and last name using FirebaseUI in Android?

According to this guide the built-in authentication of FirebaseUI should already handle this. Indeed, retrieving the current user and calling currentUser.displayName (Kotlin here) the string returned is "Lamberto Basti" that is my name concatenated with my last name. Is there a smart way to retrieve them separately?
Notice that I've enabled login with email, Facebook, Google and Twitter.
There is no API to get the separate first name and last name from Firebase Authentication. If you need the name in that format, you will need to ask your user for them (potentially pre-populating the UI based on their display name).
Note that splitting the string on a space to get the first name and last name may work in your tests, but will likely lead to problems as you roll out internally. To learn more about the intricacies, I recommend reading the W3C treatise about personal names around the world.

Android SmsMessage country code

I'm currently working on a app to blacklist SMS from a specific country, I already created my BroadcastReceiver class, which start a service to compare the phone number to the ones stored in the database.
My database contains mobile country code, and I would like to compare the received country code to those in the database, unfortunately I didn't find any method to retrieve the country code from the number. I thought that I could retrieve it with a simple substring call, but I noticed that not all the country codes are the same length, so I couldn't do this like that.
I was wondering if the prefixes were unique (that is to say if a prefix could be the prefix of another), if no, then could I start by taking the maximum size prefix and then a shorter prefix and so on ?
Could you give me a hint on how to do this ?
Thank you
Phone number rules are rather complicated and there are many special cases. To extract country code reliably, I'd suggest to use a specialized library. There's a well-known library from Google, called libphonenumber:
https://code.google.com/p/libphonenumber/
Take a look at extractCountryCode method from PhoneNumberUtil, or PhoneNumberUtil.parse which returns a PhoneNumber object on which you can call getCountryCode.
It's open source, so, alternatively, if you don't want to mess with additional libraries, you can take a look at its implementation for hints on how to handle country codes by yourself.

Which properties of android.os.Build are fixed?

I require the list of fixed properties of android.os.Build class. I've obtained the list from here I bold those that I know are fixed. By fix I mean no change by firmware update, reset factory, ...
android.os.Build.VERSION.RELEASE //The current development
codename, or the string "REL" if this is a release build.
android.os.Build.BOARD //The name of the underlying board, like "goldfish".
android.os.Build.BOOTLOADER // The system bootloader
version number.
android.os.Build.BRAND //The brand (e.g., carrier) the software is customized for, if any.
android.os.Build.CPU_ABI //The name of the instruction set (CPU type + ABI convention) of native code.
android.os.Build.CPU_ABI2 // The name of the second instruction set (CPU type + ABI convention) of native code.
android.os.Build.DEVICE // The name of the industrial design.
android.os.Build.DISPLAY //A build ID string meant for displaying to the user
android.os.Build.FINGERPRINT //A string that uniquely
identifies this build.
android.os.Build.HARDWARE //The name of the hardware (from the kernel command line or /proc).
android.os.Build.HOST
android.os.Build.ID //Either a changelist number,
or a label like "M4-rc20".
android.os.Build.MANUFACTURER //The manufacturer of the product/hardware.
android.os.Build.MODEL //The end-user-visible name for the end product.
android.os.Build.PRODUCT //The name of the overall product.
android.os.Build.TAGS //Comma-separated tags
describing the build, like "unsigned,debug".
android.os.Build.TYPE //The type of build, like
"user" or "eng".
android.os.Build.USER
Please help me complete the list
If you look at the source code to Build, you will see that all of these values -- including those you have in bold -- come from system properties files. Hence, any of these values can be modified by ROM modders or the original device manufacturer as they see fit.
I'm not going to address the woes with consistencies of Build as Mark has illustrated why there isn't a guaranteed answer. Instead I want to respond to what your purpose and intent is.
If I understand correctly, you are trying to uniquely identify a single device. I point you firstly to this answer, from which you can simply conclude that a generic solution is not possible. Either resetting factory defaults or switching SIM cards (if the device has one) will change any sort of unique ID and fool your app into thinking it's a different user.
You need to rethink what you're trying to accomplish. Why do you need to uniquely identify a device? If you're trying to identify a user, then this mindset doesn't cope for multiple devices either. This is now especially the case with Jellybean 4.2, where a device may support multiple users. See also this insightful blog post on the Android Developers Blog.
Can you have the user attach his Google account? Or account for your own service? If you can identify a user, it is then trivial to identify individual devices through UUID.randomUUID().
If I understand correctly (regarding your follow-up comment) you want to identify a device without integrating some kind of registration or login mechanism.
Instead of implementing yout own ID computation algorithm I would suggest using an OpenUDID implementation for android (see https://github.com/vieux/OpenUDID).

How do I change my Application name

I would like to make a slight change to my application's name. I read that it can work if both applications are signed with the same signature and is given the same userId then they can share information and I can migrate the original application's information to the new one. It is very important that the user gets the notification to upgrade. Will the user receive the update to upgrade if its done this way?
Your users will still get the upgrade, as long as you don't change the top level java package name.
Do you mean the actual name (human readable) or the application package? You can change the name, description, etc. at any time (though it might be confusing for existing users). On the other hand, you cannot change the package name, you need to publish a new app. Unless the current app already has the sharedUserId, set you cannot really use that option: setting it will change the UID and the application won't be able to see its own files. Two solutions to this:
export the data in some shared format (XML, CSV, JSON, etc.)
write a content provider and use a signature permission to make sure only your apps can read from it.

Make changes to contacts

I'm making android app that tells you the operator's name of your contact's number.
Is there a way to put a label containing the name of the operator next to every number directly in the contacts list?
You will need to create your own sync provider and your own RawContacts table. Fill it up with name, phone number and the data you need (e.g., the operator name). Not an easy. task There's a very nice post with lots of details here:
http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/
http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-2/
There's an example in the android Technical Resources pages: http://developer.android.com/resources/samples/SampleSyncAdapter/index.html

Categories

Resources