Android Question why show nothing by these codes?

yhyzhj

Member
read getadvertisingId:
B4X:
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Wait For (GetAdvertisingId) Complete (Id As String)
    If Id <> "" Then
        ToastMessageShow(Id,False)
    End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub GetAdvertisingId As ResumableSub
    Dim jo As JavaObject = Me
    jo.RunMethod("GetAdvertisingId", Null)
    Wait For AdvertisingId_Ready (Success As Boolean, Id As String)
    Return Id
End Sub


#if Java
import java.util.concurrent.Callable;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;

public static void GetAdvertisingId() {
   BA.runAsync(processBA, mostCurrent, "advertisingid_ready", new Object[] {false, ""}
       , new Callable<Object[]>() {
                   @Override
                   public Object[] call() throws Exception {
                       String id = AdvertisingIdClient.getAdvertisingIdInfo(mostCurrent).getId();
                       return new Object[] {true, id};
                   }
               }); }
#End If
B4X:
 

DonManfred

Expert
Licensed User
Longtime User
Start using LOG instead of Toastmessage. On some devices it does not work. Always use LOG to confirm.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Wait For (GetAdvertisingId) Complete (Id As String)
    If Id <> "" Then
        log(Id)
    End If
End Sub
What does the LOG-Command print to the LOG?
 
Upvote 0

yhyzhj

Member
You are running this on what device? Manufacturer, Android Version?

Have you tried to use another device?

Does the device have GoogleServices installed?

my device is xiaomi, android 9
i have not other android 9 device
the device have not googleservices installed
 
Upvote 0
Top