F fishwolf Well-Known Member Licensed User Longtime User Mar 7, 2020 #1 I have notice that some old devices work fine this code B4X: R.Target = R.RunStaticMethod("android.accounts.AccountManager", "get", _ Array As Object(R.GetContext), Array As String("android.content.Context")) Accounts = R.RunMethod2("getAccountsByType","com.google", "java.lang.String") and on recent devices this code: B4X: jo.InitializeStatic("android.accounts.AccountManager") GetAccounts_StartActivityForResult(jo.RunMethod("newChooseAccountIntent", Array(Null, Null, Array As String("com.google"), Null, Null, Null, Null))) how can I choose which code to execute? Thanks
I have notice that some old devices work fine this code B4X: R.Target = R.RunStaticMethod("android.accounts.AccountManager", "get", _ Array As Object(R.GetContext), Array As String("android.content.Context")) Accounts = R.RunMethod2("getAccountsByType","com.google", "java.lang.String") and on recent devices this code: B4X: jo.InitializeStatic("android.accounts.AccountManager") GetAccounts_StartActivityForResult(jo.RunMethod("newChooseAccountIntent", Array(Null, Null, Array As String("com.google"), Null, Null, Null, Null))) how can I choose which code to execute? Thanks
asales Expert Licensed User Longtime User Mar 7, 2020 #2 B4X: Dim p As Phone If p.SdkVersion < 19 Then '19 = 4.4 (old code) Else (new code) End If Upvote 0