小编Ill*_*lyk的帖子

Android应用程序内计费Trivial Drive

我正在进行像TrivialDrive这样的应用内购买.调用queryInventoryAsync:

 mHelper.queryInventoryAsync(mGotInventoryListener);
Run Code Online (Sandbox Code Playgroud)

mGotInventoryListener:

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
    public void onQueryInventoryFinished(IabResult result, Inventory inventory) {

        String price = inventory.getSkuDetails(SKU_ALL_INCLUSILE).getPrice();
        Log.d("SKU", "price " + price);
    }
};
Run Code Online (Sandbox Code Playgroud)

OnClick工作完美,我可以购买.但getPrice()方法产生NPE.请帮帮我!我想在ListView中显示SKU信息.

解决了!只需使用:

 mHelper.queryInventoryAsync(true, skuList, mGotInventoryListener);
Run Code Online (Sandbox Code Playgroud)

android in-app-purchase sku

5
推荐指数
0
解决办法
210
查看次数

Retrofit2和kotlin

我试着将Kotlin RxJava和retrofit2结合起来.

@GET("/xxxxxxxxxxxx/{id}.json")
fun getHotel(@Part("id") id : String) : Observable<Response<Hotel>>
Run Code Online (Sandbox Code Playgroud)

当我尝试调用此方法时(getHotels()):

   var subscription = HotelsFactory.getHotelService((activity.applicationContext as App)
            .client)
        .getHotel(arguments.getInt("id").toString())
        .subscribeOn(Schedulers.computation())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe({response -> showHotels(response)}) 
         {throwable ->       throwable.printStackTrace()}
    mSubscription.add(subscription)
Run Code Online (Sandbox Code Playgroud)

我拿这个:

@Part参数只能与多部分编码一起使用.

android kotlin rx-java retrofit2

3
推荐指数
1
解决办法
862
查看次数

类不能转换为 ParseObject

我在我的项目中使用 Parse.com。我想创建自己的实体类 extends Parse Object 但我有一个 java.lang.ClassCastException: com.parse.ParseObject cannot be cast to com.james.strongpeopleapp.Recipe

@ParseClassName("Recipe")
public class Recipe extends ParseObject {

    public Recipe() {
    }

    public String getRecipeName(){
        return getString("RecipeName");
    }
Run Code Online (Sandbox Code Playgroud)

注册一个子类

public class ParseApp extends Application {

    @Override
    public void onCreate() {

        ParseObject.registerSubclass(Recipe.class);
        Parse.initialize(this, "XXXXXX", "XXXXXXX");

    }
}
Run Code Online (Sandbox Code Playgroud)

异常发生在适配器的 getItemView() 中

 public class MainParseAdapter extends ParseQueryAdapter<Recipe> {

private LayoutInflater layoutInflater;

public MainParseAdapter(Context context) {

    super(context, new QueryFactory<Recipe>() {
        @Override
        public ParseQuery<Recipe> create() {
            ParseQuery query = new ParseQuery("OwnRecipeBook");
            return query; …
Run Code Online (Sandbox Code Playgroud)

java android parse-platform

2
推荐指数
1
解决办法
2402
查看次数