B4A Library Get app type

omidaghakhani1368

Well-Known Member
Licensed User
Hi.
with this library,you can detect app type
we have 2 type app in android that is "System App" and "non-System App"
this library do this action.
you must be send package name to function and it return true or false
if true,your app is system and false is non-system app.loooooool

declare varible and use "IsSystemApp" function for detect type

i cannot upload library in forum but you can download Here
Goooooooooood Luck
 

DonManfred

Expert
Licensed User
650kb library to find out if a app is a systemapp???? Sorry, but: LOL
I dont want to bother you but please tell me:
What the hell do you did there in your java-library that the lib becomes 650kb for 10 lines of code....



Try this!
B4X:
Sub isSystemapp(app As String) As Boolean
    Dim Obj1, Obj2, Obj3 As Reflector
  Dim size, i, flags As Int
  Dim result As Boolean = False

    Obj1.Target = Obj1.GetContext
  Obj1.Target = Obj1.RunMethod("getPackageManager") ' PackageManager
  Obj1.Target = Obj1.RunMethod2("getInstalledPackages", 0, "java.lang.int") ' List<PackageInfo>
  For i = 0 To Obj1.RunMethod("size") -1
      Obj2.Target = Obj1.RunMethod2("get", i, "java.lang.int") ' PackageInfo
    Dim name As String = Obj2.GetField("packageName")
        If app.ToLowerCase = name.ToLowerCase Then
            Obj3.Target = Obj2.GetField("applicationInfo") ' ApplicationInfo 
        flags = Obj3.GetField("flags")
        If Bit.AND(flags, 1)  = 0 Then
            'app is not in the system image
        Else
                ' Systemapp
                result = True
            End If 
        End If
  Next
    Return result
End Sub
B4X:
    Log("isSystemapp(com.whatsapp):"&isSystemapp("com.whatsapp"))
    Log("isSystemapp(com.android.phone):"&isSystemapp("com.android.phone"))
** Activity (main) Create, isFirst = true **
isSystemapp(com.whatsapp):false
isSystemapp(com.android.phone):true
** Activity (main) Resume **
 
Last edited:
Top