chiark / gitweb /
A little proof of concept of getting current market version number for an app
authorCiaran Gultnieks <ciaran@ciarang.com>
Wed, 27 Oct 2010 11:27:33 +0000 (12:27 +0100)
committerCiaran Gultnieks <ciaran@ciarang.com>
Wed, 27 Oct 2010 11:27:33 +0000 (12:27 +0100)
marketcheck/.gitignore [new file with mode: 0644]
marketcheck/androidmarketapi-0.3.jar [new file with mode: 0644]
marketcheck/make.sh [new file with mode: 0755]
marketcheck/protobuf-java-2.2.0.jar [new file with mode: 0644]
marketcheck/run.sh [new file with mode: 0755]
marketcheck/test.java [new file with mode: 0644]

diff --git a/marketcheck/.gitignore b/marketcheck/.gitignore
new file mode 100644 (file)
index 0000000..6b468b6
--- /dev/null
@@ -0,0 +1 @@
+*.class
diff --git a/marketcheck/androidmarketapi-0.3.jar b/marketcheck/androidmarketapi-0.3.jar
new file mode 100644 (file)
index 0000000..42a5a37
Binary files /dev/null and b/marketcheck/androidmarketapi-0.3.jar differ
diff --git a/marketcheck/make.sh b/marketcheck/make.sh
new file mode 100755 (executable)
index 0000000..c2c6f5a
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+javac -classpath androidmarketapi-0.3.jar test.java
diff --git a/marketcheck/protobuf-java-2.2.0.jar b/marketcheck/protobuf-java-2.2.0.jar
new file mode 100644 (file)
index 0000000..7a0ccde
Binary files /dev/null and b/marketcheck/protobuf-java-2.2.0.jar differ
diff --git a/marketcheck/run.sh b/marketcheck/run.sh
new file mode 100755 (executable)
index 0000000..c790786
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+java -classpath ".:androidmarketapi-0.3.jar" test $1 $2 $3
diff --git a/marketcheck/test.java b/marketcheck/test.java
new file mode 100644 (file)
index 0000000..58b8713
--- /dev/null
@@ -0,0 +1,66 @@
+\r
+import java.io.FileOutputStream;\r
+\r
+import com.gc.android.market.api.MarketSession.Callback;\r
+import com.gc.android.market.api.MarketSession;\r
+import com.gc.android.market.api.model.Market.App;\r
+import com.gc.android.market.api.model.Market.AppsResponse;\r
+import com.gc.android.market.api.model.Market.AppsRequest;\r
+import com.gc.android.market.api.model.Market.CommentsRequest;\r
+import com.gc.android.market.api.model.Market.GetImageRequest;\r
+import com.gc.android.market.api.model.Market.GetImageResponse;\r
+import com.gc.android.market.api.model.Market.ResponseContext;\r
+import com.gc.android.market.api.model.Market.GetImageRequest.AppImageUsage;\r
+\r
+class test {\r
+\r
+    /**\r
+     * @param args\r
+     */\r
+    public static void main(String[] args) {\r
+        try {\r
+            if(args.length < 3) {\r
+                System.out.println("Parameters :\n" +\r
+                        "email password package");\r
+                return;\r
+            }\r
+\r
+\r
+            String login = args[0];\r
+            String password = args[1];\r
+            String query = args.length > 2 ? args[2] : "Test";\r
+\r
+            MarketSession session = new MarketSession();\r
+            System.out.println("Login...");\r
+            session.login(login,password);\r
+            System.out.println("Login done");\r
+\r
+            AppsRequest appsRequest = AppsRequest.newBuilder()\r
+                .setQuery(query)\r
+                .setStartIndex(0).setEntriesCount(10)\r
+                .setWithExtendedInfo(true)\r
+                .build();\r
+\r
+            MarketSession.Callback callback = new MarketSession.Callback() {\r
+\r
+                @Override\r
+                    public void onResult(ResponseContext contex, Object oresp) {\r
+                        AppsResponse response = (AppsResponse)oresp;\r
+                        if(response.getAppCount() != 1) {\r
+                            System.out.println("Not in market, or multiple results");\r
+                        } else {\r
+                            App app = response.getAppList().get(0);\r
+                            System.out.println("Version Code:" + app.getVersionCode());\r
+                            System.out.println("Version:" + app.getVersion());\r
+                        }\r
+                    }\r
+\r
+            };\r
+            session.append(appsRequest, callback);\r
+            session.flush();\r
+        } catch(Exception ex) {\r
+            ex.printStackTrace();\r
+        }\r
+    }\r
+\r
+}\r