This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
//ACCOUNT KIT | |
gsClient.logIn(); | |
gsClient.logOff(); | |
//GAME SERVICE | |
//achievements | |
gsClient.showAchievements(); | |
gsClient.unlockAchievement("id"); | |
gsClient.incrementAchievement("id", increment, completionPercentage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GameServiceActivity extends AndroidApplication implements IGameServiceListener { | |
... | |
private IGameServiceClient gsClient = null; | |
@Override | |
protected void onCreate (Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
//true if You want to manage data on Cloud | |
this.gsClient = HuaweiGameServicesClient(this, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
//to get product information | |
Information skuInfo = purchaseManager.getInformation(sku); | |
if (skuInfo == null || skuInfo.equals(Information.UNAVAILABLE)) { | |
// the item is not available... | |
} else { | |
// the item is available... | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IAPActivity extends AndroidApplication { | |
... | |
//set a HuaweiPurchaseManager as PurchaseManager of your Game instance | |
game.purchaseManager = new HuaweiPurchaseManager(this); | |
//configure the HuaweiPurchaseManager | |
PurchaseManagerConfig pmc = new PurchaseManagerConfig(); | |
pmc.addOffer(new Offer().setType(OfferType.ENTITLEMENT).setIdentifier("YOUR_ITEM_SKU")); | |
pmc.addOffer(new Offer().setType(OfferType.CONSUMABLE).setIdentifier("YOUR_ITEM_SKU")); | |
pmc.addOffer(new Offer().setType(OfferType.SUBSCRIPTION).setIdentifier("YOUR_ITEM_SKU")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
switch (requestCode) { | |
case PURCHASE_STATUS_RESULT_CODE: | |
if (resultCode == RESULT_OK) { | |
if (data == null) { | |
Log.e("onActivityResult", "data is null"); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IAPActivity implements IAPListener { | |
@Override | |
public void onRegionNotSupported() { | |
} | |
@Override | |
public void onLoginRequired() { | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AnkoActivity : AppCompatActivity() { | |
lateinit var binding: ActivityAnkoBinding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val ankoComponent = ToolbarNBottombarTemplateLayout<AnkoActivity>(object : ToolbarNBottombarTemplateLayout.ToolbarNBottombarTemplateLayoutInterface { | |
override fun toolbarStyleId(): Int = R.style.ToolbarStyle | |
override fun includedLayoutId(): Int = R.layout.activity_anko |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ToolbarNBottombarTemplateLayout<A : Activity>(private val layoutInterface: ToolbarNBottombarTemplateLayoutInterface) : AnkoComponent<A> { | |
var binding: ViewDataBinding? = null | |
override fun createView(ui: AnkoContext<A>): View { | |
return ui.constraintLayout { | |
val toolbar = themedToolbar(layoutInterface.toolbarStyleId()) | |
toolbar.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, | |
ConstraintLayout.LayoutParams.WRAP_CONTENT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ToolbarNBottombarTemplateLayout<A : Activity>(private val layoutInterface: ToolbarNBottombarTemplateLayoutInterface) : AnkoComponent<A> { | |
override fun createView(ui: AnkoContext<A>): View { | |
return ui.constraintLayout { | |
val toolbar = themedToolbar(layoutInterface.toolbarStyleId()) | |
toolbar.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, | |
ConstraintLayout.LayoutParams.WRAP_CONTENT) | |
val included = include<View>(layoutInterface.includedLayoutId()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ToolbarTemplateLayout<A: Activity>(private val layoutInterface: ToolbarTemplateLayoutInterface): AnkoComponent<A> { | |
override fun createView(ui: AnkoContext<A>): View { | |
return ui.verticalLayout { | |
themedToolbar(layoutInterface.toolbarStyleId()) | |
include<View>(layoutInterface.includedLayoutId()) | |
} | |
} | |
interface ToolbarTemplateLayoutInterface{ |