hi
when i use my code module from activity main everything works fine (almost)
but when i compile it to a lib then it wont work.
i will explain first what the code module does. it is checking what installer has installed an app (by his packagename)
and when my packagename (the packagename that is running the code module) is something different then "b4a.example" it wont work (after i compile the code module to a lib) but when i try it with the code module it is working
this is the code module:
now try to use it in an example where the packagename is "b4a.example"
and then change it to "anything.com"
it will work, but then when you compile it to a lib it will not work anymore ONLY with packagename "b4a.example"
what am i doing wrong?
when i use my code module from activity main everything works fine (almost)
but when i compile it to a lib then it wont work.
i will explain first what the code module does. it is checking what installer has installed an app (by his packagename)
and when my packagename (the packagename that is running the code module) is something different then "b4a.example" it wont work (after i compile the code module to a lib) but when i try it with the code module it is working
this is the code module:
B4X:
Sub Class_Globals
Private store As String
Dim MyJavaCode As JavaObject
End Sub
Public Sub Initialize ' (Target As JavaObject)
MyJavaCode.InitializeStatic(Application.PackageName & ".store_check")
End Sub
Public Sub notfromGoogle As Boolean
store = MyJavaCode.RunMethod("isappfromplaystore", Array(Application.PackageName))
If store = Null Then
Log("*** ERROR *** could not perform check")
Return False
End If
If store = "com.android.vending" Then Return False Else Return True
End Sub
Public Sub notfromGoogle2(packagename As String) As Boolean
Dim list1 As List
list1.Initialize
Dim p As PackageManager
list1 = p.GetInstalledPackages
Dim exists As Boolean = False
For i = 0 To list1.Size - 1
If list1.Get(i) = packagename Then
exists = True
Exit
End If
Next
If exists Then
Dim str As String = MyJavaCode.RunMethod("isappfromplaystore", Array(packagename))
If str = Null Then
Log("*** ERROR *** could not perform check")
Return False
Else
If str = "com.android.vending" Then Return False Else Return True
End If
Else
Log("Could not find such Packagename, make sure Packagename is correct")
Return False
End If
End Sub
Public Sub notfromAmazon As Boolean
store = MyJavaCode.RunMethod("isappfromplaystore", Array(Application.PackageName))
If store = Null Then
Log("*** ERROR *** could not perform check")
Return False
End If
If store = "com.amazon.venezia" Then Return False Else Return True
End Sub
Public Sub notfromAmazon2(packagename As String) As Boolean
Dim list1 As List
list1.Initialize
Dim p As PackageManager
list1 = p.GetInstalledPackages
Dim exists As Boolean = False
For i = 0 To list1.Size - 1
If list1.Get(i) = packagename Then
exists = True
Exit
End If
Next
If exists Then
Dim str As String = MyJavaCode.RunMethod("isappfromplaystore", Array(packagename))
If str = Null Then
Log("*** ERROR *** could not perform check")
Return False
Else
If str = "com.amazon.venezia" Then Return False Else Return True
End If
Else
Log("Could not find such Packagename, make sure Packagename is correct")
Return False
End If
End Sub
Public Sub GetInstalledPeckageList As List
Dim p As PackageManager
p.GetInstalledPackages
Return p.GetInstalledPackages
End Sub
#if JAVA
import android.content.Context;
public static String isappfromplaystore(String packageName) {
return BA.applicationContext.getPackageManager().getInstallerPackageName(packageName);
}
#end if
now try to use it in an example where the packagename is "b4a.example"
and then change it to "anything.com"
it will work, but then when you compile it to a lib it will not work anymore ONLY with packagename "b4a.example"
what am i doing wrong?
Last edited: