javalogo

Check APK Version using Java


How to check APK version using Java?

package test;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

 

public class CekVersi_apk{

public static void main(String[] args) throws IOException {

//First of all, you must download aapt.exe. You can find it in google. Then, you can put in directory

String aapt = “\”C:\\Users\\edward\\aapt.exe\””;  //This is my path of appt.exe in desktop

//Then, put your APK to directory

String apk = “\”C:\\Users\\edward\\AndroidApplication.apk\””; //This is my path of apk in desktop

//After that, we will using this script (aapt dump badging [APK_name] )

String cmd = aapt + ” dump badging ” + apk;

System.out.println(cmd);

//Execute cmd

Process cutVideo = Runtime.getRuntime().exec(cmd);

//Result after execute

InputStream is = cutVideo.getInputStream();

BufferedReader br = new BufferedReader(new InputStreamReader(is));

String line = null;

//System.out.println(“Result  of cmd ipconfig = “);

//System.out.println(“=============================================”);

String barisPertama = null;

while( ( line = br.readLine() ) != null /*&& i==0*/ ) {

barisPertama = line;

System.out.println(barisPertama);

//i++;

break;

}

String kata[] = barisPertama.split(” “);

for(int x=0; x< kata.length;x++) {

System.out.println(kata[x]);

}

System.out.println();

System.out.println(kata[2] + kata[3]);

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s