开发者

Android In-app billing general questions

开发者 https://www.devze.com 2023-02-19 18:46 出处:网络
I know In-App billing is new i开发者_如何学Cn Android and I would like to use it, but the version requirements make me think twice whether it\'s worth the effort. I would appreciate any input from tho

I know In-App billing is new i开发者_如何学Cn Android and I would like to use it, but the version requirements make me think twice whether it's worth the effort. I would appreciate any input from those who have implemented or worked with In App Billing in detail.

  1. I still have 10% 1.5 users. In app billing requires at least 1.6 to work. Does that mean 1.5 users will crash immediately? If not, at what point does it fail? I don't want to write a bunch of hacky code to stay compatible with 1.5 users.
  2. If user reinstalls the app, are their app purchases remembered?
  3. At what point does it fail if you don't have the required Market version?

Thanks.


Regarding version support, you'll have write some extra code to detect the device OS version (see android.os.Build.VERSION) so make sure it will run on 1.5 devices. I strongly suggest isolating that code in its own class, and only instantiate that class after your version check. That way your code stays clean (not "hacky") and you don't accidentally reference a 1.6+ class from a class field. In my code, I have version test classes that look like this:

public class Android8 {
    private static final String TAG = "Android8";

    // public test variables
    public static final boolean IS_V8;
    public static final boolean AT_LEAST_V8;

    private static final Object pimpl;

    static {
        int sdk_int = 0;
        try {
            Field field = Build.VERSION.class.getField( "SDK" );
            String sdk_str = (String)field.get( null );
            sdk_int = Integer.parseInt( sdk_str );
        } catch( Throwable e ) {
        }

        IS_V8 = (sdk_int==8);
        AT_LEAST_V8 = (sdk_int>=8);

        if( AT_LEAST_V8 ) {
            pimpl = new Implementation();
        } else {
            pimpl = null;
        }
    }

    // Version safe interface
    public static void Camera_setDisplayOrientation( Camera camera, int degrees ) {
        if( AT_LEAST_V8 )
            ((Implementation)pimpl).Camera_setDisplayOrientation( camera, degrees );
    }

    // Will cause a verify error if loaded in a pre Android8 environment
    private static final class Implementation {
        public static void Camera_setDisplayOrientation( Camera camera, int degrees ) {
            camera.setDisplayOrientation( degrees );
        }
    }
}


Question 2: NO, if items are UNMANAGED. Yes if they are. That's the point with managed items, let's the Google's servers manage (remenber) the purchased items for this sort of cases.

(The "manage by user account" purchase type is useful if you are selling items such as game levels or application features. These items are not transient and usually need to be restored whenever a user reinstalls your application, wipes the data on their device, or installs your application on a new device.)

from: http://developer.android.com/guide/market/billing/billing_admin.html#billing-purchase-type

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号