how get a unique Android device ID? - java

According to the policy, we must use this method to register the user
Therefore, using email or number to register a user is not a good way for us
According to my studies, there are several ways to get a unique ID
But each has its own problems
I need a method that does not require special access from the user
Using Android ID is a good method. The problem is that it can be changed on rooted phones
And this is very bad in terms of security, of course, in Android lower than 8
Is there a specific trick or method to solve this problem?
I also know an application that does not use Android ID or mac WIFI and Pseudo-Unique ID, but does get the information according to the user's device. Is there a way to know what method it uses?

it's simple all you have to do is use the below code. this method will return android id now all you have to do is add checks at your backend.
val id = Settings.Secure.getString(
getContext()?.contentResolver,
Settings.Secure.ANDROID_ID
)

Related

How to pass a serializableExtra from different android applications?

I'm trying to send a SerializableExtra from an application to another one.
I use
resultIntent.putExtra("thing", fc);
and in the receive application :
Thing theThing = (Thing) data.getSerializableExtra("thing");
But since the applications doesn't have the same names I got the following error:
Java.lang.RuntimeException: Parcelable encountered ClassNotFoundException reading a Serializable object (name = com.test.senderapp.Thing)
And I can't modify the sender application , I need to find a way to make it works only controlling the application that receive the intent.
Thank you
Use Content Providers to achieve this.
https://developer.android.com/guide/topics/providers/content-providers.
We were discussing this issue into something pretty similar; we wanted that a keyboard could share data with another app and use it with a combination of other features.
The goal is that you define which data to expose and other apps can use that similar to what the Contact's app does; which you can access a CursorLoader to fetch all of the user's contacts.
On the other hand, as a second solution, you can make your second app receive a String and send the object as a JSON; but I'd rather prefer the first one if you're going to keep adding more objects or summing up other applications.

Why is "using getString() to get device identifiers" not recommended?

I'm trying to get my device ID to Logcat but Android Studio is giving me this warning.
using getstring to get device identifiers is not recommended
String deviceID = Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.Secure.ANDROID_ID);
Why is it not recommended?
The full warning says:
Using these device identifiers is not recommended other
than for high value fraud prevention and advanced telephony use-cases.
For advertising use-cases, use AdvertisingIdClient$Info#getId and for
analytics, use InstanceId#getId.
More info:
https://developer.android.com/training/articles/user-data-ids.html
I think Android does not recommend using this value, since it's a permanent unique id, which can be used to track your user, and he or she can't change this id or prevent you to read it. The other options given in the warning respects your user's wishes. That's why Android recommend you to use that.
It really depends on what you are going to do with that id. Privacy is a sensitive thing these days.
Also check this:
...you must abide by a user’s ‘Opt out of interest-based advertising’
or 'Opt out of Ads Personalization' setting. If a user has enabled
this setting, you may not use the advertising identifier for creating
user profiles for advertising purposes or for targeting users with
personalized advertising. Allowed activities include contextual
advertising, frequency capping, conversion tracking, reporting and
security and fraud detection.
Source: https://developer.android.com/training/articles/user-data-ids.html

How to get total number of authenticated web hits?

I am using Google Analytic API in java to get Google data for one of the website where my Google account is registered. I am able to get total number of hits between two specific dates, But I want to retrieve total number of authenticated web hits. I am not getting any proper way to get this data using Google Analytic.
The function that I have written for getting for number of hits is:
private static GaData getWebHitsByMonth(Analytics analytics, String profileId) throws IOException
{
return analytics.data().ga().get(profileId, "2013-07-01", currentDate, "ga:hits")
.setDimensions("ga:yearMonth")
.execute();
}
Can someone give me an idea about this?
Since Google Analytics has no way of knowing whether or not a user is authenticated, you have to tell it. There are two ways to approach sending this information to Google Analytics: the first (easier) is with a custom dimension, and the second (more involved, but more useful) is by using the User ID feature.
If you go the route of using a custom dimension, you'll basically just have to set that on your tracker object as soon as you know that a user is logged in. Assuming this is the first custom dimension you've made, the code might look like this.
// Set that the user is logged in.
ga('set', 'dimension1', true);
Now all subsequent hits sent to GA will include this value. (Note: you'll want to set it to false if the user logs out.)
To report on that data, you can use a filter to limit the returned results to only authenticated hits. It might look something like this: filter=ga:dimension1==true.
The second option is to use the User ID feature. The User ID is another dimension, and it allows you to track logged in users across multiple devices.
The main catch with using User ID is you are not allowed to send any personally identifiable information (PII), so it may require a bit more development work to create the User ID; however, if you're able to do that, it's probably the better route to go.
Here are some developer guides to help get you started with the implementation:
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets

How to implement custom search on the server database in Android 2.3?

I have to implement custom search in my application for android 2.3.I have some EditText in which user type one letter and then I send response to the server, retrieve all the results matches this one letter and then I need to display them in a list. When user types second button I also need to send new response and refresh data and so on.
The question how can I do this in Android 2.3? What should i use?
This seems to be too open ended with too many questions to give a really helpful answer.
What you use in your app will heavily depend on how the server's API is expecting you to communicate. I, for one, am all for hiding the specifics of what a server does from the application and put all the "smarts" behind the API. So a query like:
http:/blah.com/getresults?search=a
would result in whatever matches 'a'. If it is searching a MySql Db, processing a Google search, or accessing files on the system doesn't matter.
Your code needs to worry about the interface to the API to make queries and processing the results, whether they're free formatted text, JSON objects, or whatever.
Maybe rewording your question or provide information on what you know would help.

Android Id and its reliability

I want to generate Uuid for my app so I tried many methods for this.
1) Getting Serial number of device using android.os.Build.SERIAL(this returns "unknown" as result)
2) Dealing with device id (I don't know what it will return in case of tablet devices)
3) Getting Android id using android.provider.Settings.Secure.ANDROID_ID(seems some problem with android 2.2 version)
4) Generating Uuid using java.util.UUID
5) Generating pseudo Uuid using android.os.Build properties
All these methods shows some problems. So I am confused which to be choose? Can anybody suggest me best method?
Android Developer Blog says android id will be unique
Also I heard Android id of device can be changed on factory resetting or os updations .
So is there any chance of for duplication new android id generated during factory resetting or os updations ?
NB:Suppose A Condition
My question is what will happened same 2 device Model of same manufacture will under go restore or os updations.the Android id will change. I am asking about this new id. Will there any chance for android id be same in both device?
The ANDROID_ID is generated each time you initialize the device (after reset, etc.). It doesn't depend on model, serial no., etc. Even if you have two identical devices, their ANDROID_ID's after reset should be different. The ID is not particular special, except that it is global for the device. You can achieve the same thing with an UUID for your app.
Yes, there is a chance of duplicate ID's, but it's negligible.
There's 2^64 possible values for ANDROID_ID, and they are generated with some random function. But it is very very very unlikely that you will ever see a duplicate value - search for discussions about GUID uniqueness to get the point.
In short: you can assume that ANDROID_ID is unique.
Creating unique id's for android device has been discussed vivdly in this link In short use this.
import android.provider.Settings.Secure;
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);

Categories

Resources