我正在尝试来自的示例代码here。但我的应用程序崩溃了。
我添加了日志记录,发现它崩溃了session.flush();
所以我删除了那条线,它不再崩溃了。
但还没有达到onResult
打回来。
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 = "[email protected]";
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";
有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)