1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-02 09:10:11 +02:00

A little proof of concept of getting current market version number for an app

This commit is contained in:
Ciaran Gultnieks 2010-10-27 12:27:33 +01:00
parent 779ed11efc
commit 817b3bbaf1
6 changed files with 71 additions and 0 deletions

1
marketcheck/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.class

Binary file not shown.

2
marketcheck/make.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
javac -classpath androidmarketapi-0.3.jar test.java

Binary file not shown.

2
marketcheck/run.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
java -classpath ".:androidmarketapi-0.3.jar" test $1 $2 $3

66
marketcheck/test.java Normal file
View File

@ -0,0 +1,66 @@
import java.io.FileOutputStream;
import com.gc.android.market.api.MarketSession.Callback;
import com.gc.android.market.api.MarketSession;
import com.gc.android.market.api.model.Market.App;
import com.gc.android.market.api.model.Market.AppsResponse;
import com.gc.android.market.api.model.Market.AppsRequest;
import com.gc.android.market.api.model.Market.CommentsRequest;
import com.gc.android.market.api.model.Market.GetImageRequest;
import com.gc.android.market.api.model.Market.GetImageResponse;
import com.gc.android.market.api.model.Market.ResponseContext;
import com.gc.android.market.api.model.Market.GetImageRequest.AppImageUsage;
class test {
/**
* @param args
*/
public static void main(String[] args) {
try {
if(args.length < 3) {
System.out.println("Parameters :\n" +
"email password package");
return;
}
String login = args[0];
String password = args[1];
String query = args.length > 2 ? args[2] : "Test";
MarketSession session = new MarketSession();
System.out.println("Login...");
session.login(login,password);
System.out.println("Login done");
AppsRequest appsRequest = AppsRequest.newBuilder()
.setQuery(query)
.setStartIndex(0).setEntriesCount(10)
.setWithExtendedInfo(true)
.build();
MarketSession.Callback callback = new MarketSession.Callback() {
@Override
public void onResult(ResponseContext contex, Object oresp) {
AppsResponse response = (AppsResponse)oresp;
if(response.getAppCount() != 1) {
System.out.println("Not in market, or multiple results");
} else {
App app = response.getAppList().get(0);
System.out.println("Version Code:" + app.getVersionCode());
System.out.println("Version:" + app.getVersion());
}
}
};
session.append(appsRequest, callback);
session.flush();
} catch(Exception ex) {
ex.printStackTrace();
}
}
}