how to get list of executable applications ?

peacemaker

Expert
Licensed User
Longtime User
Some suggestion on Java was:

B4X:
final PackageManager pm = getContext().getPackageManager(); //Package Manager
// get a list of installed applications.
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); 
// making filter of applications of ACTION_MAIN
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); // filtering the apps that are exacutable 
List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0); // applying the filter
Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm)); // sorting the apps list

Is it possible on b4a ?
 

peacemaker

Expert
Licensed User
Longtime User
Maybe GetCategories or hasCategory method can anyhow be used to check CATEGORY_LAUNCHER of the intent of each app from PackageManager ?

But how ?
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Ohhhh...
The simplest and genial way ! :)
Thanks, Erel.

But some strange app found - "Contacts" com.android.contacts, that is initialized OK, but cannot be started:

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.contacts/com.android.internal.app.ResolverActivity}; have you declared this activity in your AndroidManifest.xml?
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Seems, it's due to several MAIN activities. So how to process with them ? :-(
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
OK, Erel, i see.
But then another question - why such app cannot be started from b4a code?
It's just "CONTACTS" application "com.android.contacts" that exists in any Android emulator or real device.

list1 = r.RunMethod4("queryIntentActivities", Array As Object(Intent1, 0), Array As String("android.content.Intent", "java.lang.int"))

returns the empty list, as this app has no activities, but this app is started well by another Launchers.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
OK. But v.2.3 Emulator and LG P500 seem to have the same CONTACTS app.

And final question - how to make the list of really executable apps on the device as in an standard Launcher app, and start any one at user tap for sure ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
OK. But v.2.3 Emulator and LG P500 seem to have the same CONTACTS app.

And final question - how to make the list of really executable apps on the device as in an standard Launcher app, and start any one at user tap for sure ?

This CONTACTS is executable for sure in another Launchers, but ..... not from my b4a sample...:(

Maybe it's not important - but it's wrong Launcher, if it cannot start an existing user-interface app...
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Sure, but it means i cannot get correct intent for starting such app. That can be on device - any.
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
So, how do you get a list of installed apps with a string like 'calc'? The reason is that some devices don't have the original internal calculator. So if you were to do a search for 'calc' it'd come up with the calculator for that device. Then you have it launch. Code please as I understand the how, just not the coding portion.
 
Upvote 0
Top