简体   繁体   English

Android显示解锁成就通知另一个活动

[英]Android show unlock Achievement notification another activity

I have a method that is doing unlock achievement in ExampleA Activity. 我有一个方法可以在ExampleA活动中实现解锁成就。 I call this method from ExampleB Activity. 我从ExampleB活动中调用此方法。 It is working correctly except unlock notification is showing when I open ExampleA. 它正常工作,但打开ExampleA时显示解锁通知。 I want to show unlock notification in ExampleB. 我想在ExampleB中显示解锁通知。

ExampleA.java ExampleA.java

...
public static void unlockTheAchievement(int achievementId, AppCompatActivity activity) {
            if (isSignedIn()) {
                Games.Achievements.unlock(mGoogleApiClient, activity.getString(achievementId));
            }
}

ExampleB.java ExampleB.java

ExampleA.unlockTheAchievement(R.string.achievement_level3, ExampleB.this);

Thank you. 谢谢。

Maybe there is a part of your code that is calling the unlockTheAchievement in ExampleA activity. 也许您的代码中有一部分正在ExampleA活动中调用unlockTheAchievement As stated here , you can use startActivityForResult or you can pass the values from one activity to another using intents and do what is required. 如前所述在这里 ,你可以使用startActivityForResult ,也可以从一个活动值传递到另一个使用意图和做的是需要什么。 But it depends on what you intend to do in the method. 但这取决于您打算在该方法中执行的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM