Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extract package name from apk file

In my java application, I have tried to get the package name of an android application. I have tried it by executing command line argument. The command is :

aapt dump badging <apk file>

And this command returned whole meta data of the application.I have to extract the package name from the returned string suppose named 'result' ;

like image 209
user3540345 Avatar asked Nov 18 '25 20:11

user3540345


1 Answers

hoe you are looking for this try this code :

String line;
        while ((line = r.readLine()) != null) {
            int ind = line.indexOf("package: name=");
            if (ind >= 0) {
                String yourValue = line.substring(ind + "default =".length(), line.length() - 1).trim(); // -1 to remove de ";"
                System.out.println(yourValue);
          }
like image 80
droidev Avatar answered Nov 20 '25 11:11

droidev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!