How do I use the unofficial Android Market API?(如何使用非官方的 Android Market API?)
问题描述
我正在尝试here<的示例代码/代码>.但是我的应用程序崩溃了.
I'm trying the sample code from here
. But my app is crashing.
我添加了日志记录,发现它在 session.flush();
处崩溃,所以我删除了该行,它不再崩溃了.
I added logging and found out that it's crashing at session.flush();
so I removed that line and it doesn't crash anymore.
但它没有到达 onResult
回调.
But it doesn't reach the onResult
callback.
package com.mytest.app;
import com.gc.android.market.api.MarketSession;
import com.gc.android.market.api.MarketSession.Callback;
import com.gc.android.market.api.model.Market.AppsRequest;
import com.gc.android.market.api.model.Market.AppsResponse;
import com.gc.android.market.api.model.Market.ResponseContext;
import android.app.Activity;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.util.Log;
public class MarketAPITestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d("Market API", "Started");
String email = "somebody@gmail.com";
String pass = "mypass";
String AndroidId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
MarketSession session = new MarketSession();
session.login(email,pass);
session.getContext().setAndroidId(AndroidId);
String query = "maps";
AppsRequest appsRequest = AppsRequest.newBuilder()
.setQuery(query)
.setStartIndex(0).setEntriesCount(10)
.setWithExtendedInfo(true)
.build();
session.append(appsRequest, new Callback<AppsResponse>() {
@Override
public void onResult(ResponseContext context, AppsResponse response) {
Log.d("Market API", "Got response");
}
});
session.flush();
}
}
推荐答案
androidId
有问题.而不是:
String AndroidId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
使用这个:
String AndroidId = "dead000beef";
它有效.
这篇关于如何使用非官方的 Android Market API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用非官方的 Android Market API?


基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01