Skip to main content
Samsung Developer Program

Initialize IAP Helper

You modify your Android app's MainActivity class in order to support the sale of in-app items registered to your Android app.


The example code in this section demonstrates how to implement a listener, hard code an in-app item ID, instantiate an IapHelper object, and set the IAP operating mode.

For more details, see:

public class MainActivity extends AppCompatActivity implements OnPaymentListener {
    // Please change ITEM_ID for your application's in-app items.     
    // ========================================================================     
    private static final String ITEM_ID  = "Nuclear";     
    // ========================================================================

    private IapHelper    mIapHelper  = null;

    @Override     
    protected void onCreate(Bundle savedInstanceState) {         
        super.onCreate(savedInstanceState);         
        setContentView(R.layout.activity_main);
        
        mIapHelper = IapHelper.getInstance(this);         
        mIapHelper.setOperationMode(OPERATION_MODE_PRODUCTION);     
    }
}