0

I am working on an app which needs to run external LuaJ Interpreter to get the information of the apps running at the system up to now. I found there an code in Java, but not on LuaJ.

This is my attempt to do something.

local pm = activity:getPackageManager()
local packages = pm:getInstalledApplications(activity.GET_META_DATA)
local size = packages:size()

for i=0,size-1 do
    packageInfo = packages:get(i)
    if not packageInfo:equals(flags) and not packageInfo:equals(FLAG_SYSTEM) and not packageInfo:equals(FLAG_STOPPED) then
       print(packageInfo.packageName)
    end
end

But there was a problem with "equals(...)". Please help)

WANDEL
  • 1
  • 3

1 Answers1

0

This is an answer to myself.

    local pm = activity:getPackageManager()
    local packages = pm:getInstalledApplications(activity.GET_META_DATA)
    local size = packages:size()

    local packageInfo, packageName, ai, str

    for i=0,size-1 do
        packageInfo = packages:get(i)
        packageName = packageInfo.packageName
        ai = pm:getApplicationInfo(packageName)
        if ai and string.find(packageInfo.sourceDir, "^/data/app/") and pm:getLaunchIntentForPackage(packageName) then --nonSystem app
            print(pm:getApplicationLabel(ai))
        end
    end
WANDEL
  • 1
  • 3