Android Question google service framework id (how to get it?)

pliroforikos

Active Member
Licensed User
Hello everyone
I'm trying to figure how to get gsf id key . I tried this method and writed it as shown bellow.

B4XmainPage:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

#If JAVA
public String getGsfAndroidId(Context context)
{
    Uri URI = Uri.parse("content://com.google.android.gsf.gservices");
    String ID_KEY = "android_id";
    String params[] = {ID_KEY};
    Cursor c = context.getContentResolver().query(URI, null, null, params, null);
    if (!c.moveToFirst() || c.getColumnCount() < 2)
        return null;
    try
    {
        return Long.toHexString(Long.parseLong(c.getString(1)));
    }
    catch (NumberFormatException e)
    {
        return null;
    }
}
#End If

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
End Sub

Public Sub Initialize
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

Sub Button1_Click
    xui.MsgboxAsync(getGsf, "B4X")
End Sub

Private Sub getGsf As String
    Dim jo As JavaObject = Me
    Dim str As String = jo.RunMethod("getGsfAndroidId", Null)
    Return str
End Sub

but i am getting an error :
cannot find symbol
public String getGsfAndroidId(Context context)


I also put this <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> at manifest

Any ideas please?
 

Attachments

  • Project.zip
    13.8 KB · Views: 300

pataridis

Member
Licensed User
Android_id is totally different. There is a known bug for Android_ID with a popular handset from a manufacturer where every instance have the same ANDROID_ID. Clearly, the solution is not 100% reliable.
Google Service Framework ID (GSF ID) on the other hand is totally unique and it changes only on hard reset. You can't move it or backup it, to another device (or even to the same device) if you hard reset it.
So, i want it too!
How to get it from Β4Α?

Thanx
 
Upvote 0

pliroforikos

Active Member
Licensed User
Finaly after a lot of research i found EasyDeviceInfo (with inline Java Code) and made a lib with Simple Library Compiler tool.

i have a little java knowledge so maybe it doesnt work with all methods. I've checked gsfID and it works.
For gsfID we need to declare in manifest:
B4X:
 <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />)

I don't know what kind of permissions needs the other methods...

And of course we need JavaObject library to be selected.
 

Attachments

  • gsfLib.zip
    1.5 KB · Views: 351
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…