Programming access to Android Market

简介:

如果你在Android Market上发布了程序,怎么通过程序访问,查看程序的信息呢?谷歌大神为我们提供了--An open-source API for the Android Market,另外,也给Ruby和PHP都留了接口,当然了访问是需要Google帐户滴,更多信息请看考:http://code.google.com/p/android-market-api/

OK,废话少说,That's it!

Current progress

  • You can browse market with any carrier or locale you want.
  • Search for apps using keywords or package name.
  • Retrieve an app info using an app ID.
  • Retrieve comments using an app ID.
  • Get PNG screenshots and icon

Requirement:

需要把这两个JAR导入项目中,由于很好理解,代码就不加注释了 :-)

HowToSearchApps  :

You can search by package using :

 
 
  1. String query = "pname:<package>"

By developper name :

 
 
  1. String query = "pub:<name>"
 
 
  1. String query = "pname:com.luckyxmobile.timers4me";// 通过包名查找程序
  2. MarketSession session = new MarketSession();  
  3. session.login("your gmail account""your password");  
  4. AppsRequest appsRequest = AppsRequest.newBuilder().setQuery(query).setStartIndex(0).setEntriesCount(10).setWithExtendedInfo(true).build();  
  5. session.append(appsRequest, new MarketSession.Callback<AppsResponse>() {  
  6. @Override 
  7. public void onResult(ResponseContext context, AppsResponse response) {  
  8. TextView text = (TextView) findViewById(R.id.text);  
  9. String id = response.getApp(0).getId();  
  10. String creatorID = response.getApp(0).getCreatorId();  
  11. String creator = response.getApp(0).getCreator();  
  12. String packageName = response.getApp(0).getPackageName();  
  13. String price = response.getApp(0).getPrice();  
  14. String rating = response.getApp(0).getRating();  
  15. int ratingCount = response.getApp(0).getRatingsCount();  
  16. String title = response.getApp(0).getTitle();  
  17. String version = response.getApp(0).getVersion();  
  18. int versionCode = response.getApp(0).getVersionCode();  
  19. int serializedSize = response.getApp(0).getSerializedSize();  
  20. ExtendedInfo extendedInfo = response.getApp(0).getExtendedInfo();  
  21. text.setText("id:" + id + "\nCreatorId:" + creatorID  
  22. "\nCreator:" + creator + "\nPackageName:"+ packageName + "\nPrice:" + price + "\nrating:"+ rating + "\nRatingCount:" + ratingCount + "\ntitle:" 
  23. + title + "\nVersion:" + version + "\nversionCode:" 
  24. + versionCode + "\nDownloadsCount:" 
  25. + extendedInfo.getDownloadsCount()  
  26. "\nDownloadsCountText:"+extendedInfo.getDownloadsCountText()+ "\nInstallSize:" + extendedInfo.getInstallSize()  
  27. "\nSerializedSize:" + serializedSize+ "\nDecription:" + extendedInfo.getDescription()+ "\nContactEmail:" + extendedInfo.getContactEmail()+ "\nContactPhone:" + extendedInfo.getContactPhone()+ "\nContactWebsite:" 
  28. + extendedInfo.getContactWebsite());  
  29.             }  
  30.         });  
  31. session.flush();//发送并刷新 

 这是Timers4Me的运行结果:

breezy

HowToGetAppComments:

 
 
  1. CommentsRequest commentsRequest = CommentsRequest.newBuilder().setAppId("7065399193137006744").setStartIndex(0).setEntriesCount(10).build();session.append(commentsRequest, new Callback<CommentsResponse>() {    
  2. @Override public void onResult(ResponseContext context, CommentsResponse response) {        
  3. System.out.println("Response : " + response);  
  4. // response.getComments(0).getAuthorName()      
  5. // response.getComments(0).getCreationTime()    
  6. // ...   
  7.     } });    
  8. session.flush();   

HowToGetAppScreenshot   :

 
 
  1. GetImageRequest imgReq = GetImageRequest.newBuilder().setAppId("-7934792861962808905").setImageUsage(AppImageUsage.SCREENSHOT).setImageId("1").build();       
  2. session.append(imgReq, new Callback<GetImageResponse>() {   
  3. @Override public void onResult(ResponseContext context, GetImageResponse response) {      
  4. try {                        
  5. FileOutputStream fos = new FileOutputStream("icon.png");      
  6. fos.write(response.getImageData().toByteArray());      
  7. fos.close();                           
  8. catch(Exception ex) {      
  9. ex.printStackTrace();     
  10. }}});   
  11. session.flush();  

以上只是抛砖引玉,更多精彩,只有动手才能看到,good luck!










本文转自 breezy_yuan 51CTO博客,原文链接:http://blog.51cto.com/lbrant/431834,如需转载请自行联系原作者
目录
相关文章
|
XML Android开发 数据格式
android google market 不能搜索到facebook或显示不兼容
android google market 不能搜索到facebook或显示不兼容
149 0
|
Android开发 Java
进入 android market 网页 或是应用
引用:http://blog.csdn.net/feng88724/article/details/6606464 在实际需求,有可能会有给应用评价这样的功能,通常这样的功能都会跳转到Android Market来让用户评论。
673 0
|
Android开发 Windows Go
如何在G1上安装非android market的apk
Here we share to you T-Mobile G1 tips and tricks, how to install apk file.
918 0
|
7天前
|
Android开发 开发者 UED
探索安卓应用开发中的UI设计趋势
随着移动应用市场的不断发展和用户需求的变化,安卓应用的UI设计趋势也在不断演进。本文将深入探讨当前安卓应用开发中的UI设计趋势,包括暗黑模式、原生化设计、动效设计等方面的发展趋势,为开发者提供参考和启发。
|
7天前
|
安全 网络安全 量子技术
网络安全与信息安全:漏洞、加密技术与安全意识的探索安卓应用开发中的内存管理策略
【5月更文挑战第31天】随着互联网的普及,网络安全问题日益严重。本文将深入探讨网络安全漏洞、加密技术以及安全意识等方面的问题,以期提高公众对网络安全的认识和防范能力。
|
7天前
|
机器学习/深度学习 算法 Android开发
安卓应用开发:打造高效通知管理系统
【5月更文挑战第31天】在移动应用的海洋中,用户经常被各种推送通知所困扰。一个精心设计的通知管理系统对于提升用户体验至关重要。本文将探讨如何在安卓平台上开发一个高效的通知管理系统,包括系统设计原则、实现机制以及性能优化策略,旨在为开发者提供一套可行的解决方案,以减少用户干扰并提高应用的用户留存率。