mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
A little proof of concept of getting current market version number for an app
This commit is contained in:
parent
779ed11efc
commit
817b3bbaf1
1
marketcheck/.gitignore
vendored
Normal file
1
marketcheck/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.class
|
BIN
marketcheck/androidmarketapi-0.3.jar
Normal file
BIN
marketcheck/androidmarketapi-0.3.jar
Normal file
Binary file not shown.
2
marketcheck/make.sh
Executable file
2
marketcheck/make.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
javac -classpath androidmarketapi-0.3.jar test.java
|
BIN
marketcheck/protobuf-java-2.2.0.jar
Normal file
BIN
marketcheck/protobuf-java-2.2.0.jar
Normal file
Binary file not shown.
2
marketcheck/run.sh
Executable file
2
marketcheck/run.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
java -classpath ".:androidmarketapi-0.3.jar" test $1 $2 $3
|
66
marketcheck/test.java
Normal file
66
marketcheck/test.java
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user