PkgUtils : An extension to work with Packages

1.Introduction

PkgUtils is basically related to Package and Package Manager and that is why it is similar to Package Utilities component already available in Kodular.
But it has a few more methods in comparison to native component :slightly_smiling_face:

Latest Version: 5.1
Last Updated: 2020-11-11T18:30:00Z

2.Blocks

Methods/Functions

image
image
image
image

3.Usage

A small documentation…

scrnli_12_21_2019_12-01-49 PM

Returns app name from package

scrnli_12_21_2019_12-02-30 PM

Returns app version code from package

scrnli_12_21_2019_12-03-11 PM

Returns app version name from package

Checks whether specific permission is granted to current app or not

scrnli_12_21_2019_12-04-51 PM

Checks whether specific permission is granted to particular app or not

scrnli_12_21_2019_12-06-56 PM

Checks whether system has a particular feature or not

scrnli_12_21_2019_12-07-43 PM

Returns first install time of a package or app

scrnli_12_21_2019_12-08-21 PM

Returns path to icon of an app

image

Returns a list of installed packages/apps.You can also filter list by system apps.

scrnli_12_21_2019_12-09-26 PM

Returns true if a particular package is installed else false

scrnli_12_21_2019_12-10-38 PM

Returns last update time of a package/app

scrnli_12_21_2019_12-10-54 PM

Returns target sdk version of an app

scrnli_12_21_2019_12-11-07 PM

Checks whether an app is system app or not

component_method (12)

Returns true if device is booted in safe mode else false

component_method (13)

Returns a list of system available features

image

Returns uid associated with particular package

image

Returns a list of currently running apps

image

Returns package name of the installer of particular package

image

Returns a list of permissions used by a package

image

Checks whether given package/app is running in foreground or not

image

Tries to uninstall given package

image

Tries to install app from apk file.It does not need full path.

Tries to get icon of given package and sets to given image’s picture

Launches app from package name

image

Creates a home screen shortcut of app

4.Download

Aix:
com.sunny.PkgUtils.aix (16.3 KB)

5.Credits

I would like to say thank you to following for helping me to make PkgUtils:
@yusufcihan

and also thank you to @Aditya_Singh for this great idea
also a lot of thanks to @msr79526 for testing and his precious advices :heart_eyes:

6.Liked PkgUtils/Support Me

Kindly PM me if you want to donate.
Thank you :slightly_smiling_face:

7.Updates/Bug Fixes

ChangeLog Version 2

New blocks
Some new blocks have been added:-
image
image
image
image
image
image
image

Changes/Bug Fixes

  • Added filter in ‘InstalledApps’ method
  • Some other minor changes
ChangeLog Version 3

Changes

  • Added necessary permissions in extension
    Thanks to @bodymindpower
  • Fixed grammar and spelling mistakes
  • Some internal changes to reduce aix size (16.1 > 14.5 KB)
ChangeLog Version 4

New blocks
image

Bug Fixes

ChangeLog Version 5

New Blocks

  • Added CreateShortcut method
    image

Bug Fixes

  • Fixed (finally) bug in InstallApp method

Changes

  • FirstInstallTiime and LastInstallTime methods will now return epoch timestamp
  • Some minor change in Icon method
  • Removed RunningAppsList method
ChangLog Verson 5.1
  • AndroidX support (awaiting release since November 2020)
47 Likes

Great work! Keep it up :smile:

1 Like

Great extension!!!

2 Likes

great extention.
The Installed Apps Block is easer to understand bcoz it returnes it in list format

2 Likes

Great work, clicked on mini url 2 times, and downloaded twice, :heart_eyes:

2 Likes

This is the best way of presenting an extension, by explaining in detail what each block does and providing examples. Some of us are old people, and we are a little slow you know? :grin: Thanks!

8 Likes

ChangeLog Version 2

New blocks
Some new blocks have been added:-
image
image
image
image
image
image
image

Changes/Bug Fixes

  • Added filter in ‘InstalledApps’ method
  • Some other minor changes

Thanks to @msr79526 for his tests and advice :heart_eyes:

8 Likes

Hi

This uninstallation code is not working. All other code is working fine in MIT App Inventor,
image

Hi @Vinod_Kotiya Welcome to Kodular Community
Since I have not tested that method on all android versions so I am not sure on which versions it will not work.
Can you provide more details?

2 Likes

@vknow360 Please add this permission to the Manifest, to be able to uninstall package from devices with API > 28:

<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>

See here:

https://developer.android.com/reference/android/Manifest.permission

4 Likes

Thank you @bodymindpower :heart_eyes:
I will try to fix it as soon as possible :+1:

2 Likes

Great, and also add this permission:

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

to install package on devices with API > 25.

1 Like

Thank you.

I have already added all necessary permissions and just going to test it :smile:

1 Like

ChangeLog Verson 3

Changes

  • Added necessary permissions in extension
    Thanks to @bodymindpower
  • Fixed grammar and spelling mistakes
  • Some internal changes to reduce aix size (16.1 > 14.2 KB)
3 Likes

Great service, updating so quickly. :+1:

7 Likes

It is one of the best extension developers :heart_eyes:

2 Likes

vknow360 Anke Hi, Thanks for your support. I am affraid. It is still not working. I tried new AIX, source code attached here.
Sunny this uninstall instruction is unresponsive. Hope you can find the glitch or give proper sample code. Thanks.
uninstall (4).aia (15.2 KB)

You might need to build your app, as those permissions above won’t work in companion

2 Likes

Eureka… Now it worked… as pointed out by Boban i should build it. It wont work in companion. Thanks anke, Taifun vknow360 here is final code… must built it to run…

uninstall (5).aia (15.2 KB)

1 Like

Of course not with Companion, because the permission ( REQUEST_DELETE_PACKAGE S) is not declared in Companion (apk).

And as I already said in the AI2 forum, you cannot uninstall a pre-installed system app (like YouTube). There is no problem to unintall all other apps.

Btw, if you post the same story also in the AI2 forum , then at least let us know.