I am trying to develop an android application where i have the following requirement. Is there any way through code, i can get the list of apps installed on devices in debug mode.
Thanks in advance.
EDIT - I tried the following code.
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (int i=0; i < packages.size(); i++)
{
if ((packages.get(i).flags & ApplicationInfo.FLAG_SYSTEM) == 1)
{
//This is for System applications
}
else
{
boolean isDebuggable = (0 != ( getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE ) );
if((pm.getLaunchIntentForPackage(packages.get(i).packageName)!=null) && (isDebuggable = true) )
{
// Only For Apps with debug mode set true, this line should get executed
// But this does not happens
}
}
}
Here you go,
Intent main = new Intent(Intent.ACTION_MAIN, null);
main.addCategory(Intent.CATEGORY_LAUNCHER);
List pkgAppsList = context.getPackageManager().queryIntentActivities( main, 0);
This should give you enough information in order to kick off an application.
I tried various methods but as per my understanding, we cannot get the list of apps in debug mode seperately.
By using the flags, we can only get for the app which has this code and not other apps running on device.
Thanks anyways. If anybody has a different thought, please let me know.
From Justin's answer
Kotlin
val allIntent = Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
val allApps = packageManager.queryIntentActivities(allIntent, 0)
val debugApps = arrayListOf<ActivityInfo>()
allApps.forEach {
val appInfo = (packageManager.getApplicationInfo(
it.activityInfo.packageName,
0
))
if (0 != appInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) {
debugApps.add(it.activityInfo)
}
}
debugApps.forEach {
Log.d("debugApps", it.packageName)
}
It is possible to get all the apps that are in debug mode.
In my device, I get all the apps that I've installed using Android studio.
Related
I'm trying get a list of all documents in a device without breaking the illusion of being in my app like file picker does. I test with my physical device and it was working before but since I bought a better device using Android 11, I've been having issues.
This is what I did back then that worked. After getting permission errors for trying to access /storage/emulated/0/Android, I think there has been a permission update so I am now temporarily avoiding that folder manually but still I couldn't see any files until I added .mp4 to the allowed extensions and then it showed only my videos.
List<File> bookList = [];
List<List<String>> bookPropertyList = [];
fetchBooks() async {
var rootPath = await ExternalPath.getExternalStorageDirectories();
var docPath = Directory(rootPath[0]);
var docassets = docPath.listSync(recursive: true, followLinks: true);
for (FileSystemEntity asset in docassets) {
if (asset is File) {
String name = basename(asset.path);
if (name.endsWith('.pdf') ||
name.endsWith('.PDF') ||
name.endsWith('.txt') ||
name.endsWith('.TXT') ||
name.endsWith('.doc') ||
name.endsWith('.DOC') ||
name.endsWith('.docx') ||
name.endsWith('.DOCX')) {
String size = await getSize(asset.statSync().size, 1);
int day = asset.statSync().modified.day;
int month = asset.statSync().modified.month;
int year = asset.statSync().modified.year;
String date = '$day/$month/$year';
List<String> docProperty = [name, size, date];
bookPropertyList.add(docProperty);
File? file = asset.absolute;
bookList.add(file);
}
}
}
}
Is there a reason why it wouldn't show my files?
And is there a better way to get the files without leaving the app? Perhaps a light package I could use.
I'm doing some android analysis and need to find all the android app that have targetSdkversion over 23, right now I'm reverse engineering all the apk packages to see this...Wondering if there's more easy way to get this information given an app name?
Thanks :)
you can do that by this code:
int sdkVersion = 0;
IPackageManager packageManager = AppGlobals.getPackageManager();
try {
ApplicationInfo appInfo = packageManager.getApplicationInfo(yourAppName, 0);
if (applInfo != null) {
sdkVersion = applicationInfo.targetSdkVersion;
}
}
I have a project where use a custom Android launcher (android 4.2.2). The launcher shows games which are made in Adobe Air. Now we want to expand the list of games with Unity games.
To show the games we use the PackageManager and filter on name e.g.: air.Bimii. Namespace of both technologies are kept the same: air.BimiiMath, air.BimiiABC and so on.
The problem is that the games made in Unity are not listed when using:
private ArrayList<LocalAppDetail> initAppList(){
ArrayList<LocalAppDetail> res = new ArrayList<LocalAppDetail>();
PackageManager main_package_manager = main_activity.getPackageManager();
List<PackageInfo> packs = main_package_manager.getInstalledPackages(0);
for (int i = 0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
if ((p.versionName == null)) {
continue;
}
//Store Local Appdetail
LocalAppDetail newInfo = new LocalAppDetail();
newInfo.name = p.applicationInfo.loadLabel(main_package_manager).toString();
newInfo.pname = p.packageName;
newInfo.versionName = p.versionName;
newInfo.versionCode = p.versionCode;
newInfo.icon = p.applicationInfo.loadIcon(main_package_manager);
//Parse if the app meets requirements
if (newInfo.name.toLowerCase().contains(MiscData.apk_filter_text)) {
if(!newInfo.name.toLowerCase().contains("launcher")) {
if(!newInfo.name.toLowerCase().contains("rfid")){
res.add(newInfo);
}
}
}
}
//Store The Collection
return res;
}
but when i try using ADB: adb shell pm list packages -f air this is the result:
package:/data/app/air.BimiiFarm-1.apk=air.BimiiFarm
package:/data/app/air.BimiiFood-1.apk=air.BimiiFood
package:/data/app/air.nl.mediaheads.klassewinkel-1.apk=air.nl.mediaheads.klassewinkel
package:/system/app/Air.apk=com.adobe.air
package:/mnt/asec/nl.mediaheadsair.bimiiRekenen-1/pkg.apk=nl.mediaheadsair.bimiiRekenen
So the game is there (last in the list). The name is pkg.apk and the location is different. Do you guys have an idea about how to catch all the games in a list show we can launch them?
Help would be great! Thanks in advance
Update Sigh, it was an option in Unity Player settings. Install Location should be put on "Force Internal". What a world, what a world.
I am new to android. I want to hide other app icons from their package names. I get apps package name using this code
final PackageManager pm = getPackageManager();
List<ApplicationInfo> PackList = pm
.getInstalledApplications(PackageManager.GET_META_DATA);
for (int i = 0; i < PackList.size(); i++) {
ApplicationInfo PackInfo = PackList.get(i);
// if (((PackInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) !=
// true) {
appsList.add(new AppPojo(PackInfo
.loadLabel(getPackageManager()).toString(),
PackInfo.packageName.toString(), "0"));
// }
}
Give package name of a particular app, is it possible to hide its icon??
Give package name of a particular app, is it possible to hide its icon?
No. You are welcome to write your own home screen which filters out apps, but you cannot force other home screens, or anything else, from showing whatever they want.
Hi i used the following code from this tutorial to list all of the installed applications in an app i'm working on.
http://impressive-artworx.de/2011/list-all-installed-apps-in-style/
I changed the onClick to my own dialog and what i now need to do is be able to get the location of the app. That is if it's in /system/app or /data/app i'd like to be able to toast the entire path to the pressed app but can't figure out how to do this. I can get the packagename by doing app.getPackageName() in the onClick but how can i get the apks path with this? Thank you for any suggestions or help it is much appreciated!
After a bit more googling i got what i was looking for
PackageManager m = getPackageManager();
String s = getPackageName();
PackageInfo p = m.getPackageInfo(s, 0);
s = p.applicationInfo.sourceDir;
worked very well found it here
Get Application Directory
thanks for the help it helped with my googling as to what to look for
Take a look at this . In particular the snippet with publicSourceDir .
List<PackageInfo> packs = packageManager.getInstalledPackages(0); //PackageManager.GET_META_DATA
for(int i=0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
ApplicationInfo a = p.applicationInfo;
// skip system apps if they shall not be included
if ((!includeSysApps) && ((a.flags & ApplicationInfo.FLAG_SYSTEM) == 1)) {
continue;
}
App app = new App();
app.setTitle(p.applicationInfo.loadLabel(packageManager).toString());
app.setPackageName(p.packageName);
app.setVersionName(p.versionName);
app.setVersionCode(p.versionCode);
CharSequence description = p.applicationInfo.loadDescription(packageManager);
app.setDescription(description != null ? description.toString() : "");
apps.add(app);
}
u can use this code to get the information of installed Applications.