Just as the title says. I implemented the Snackbar feature in my app, the first time the snackbar pops up it doesn't show the action, but on the second time it does. The code is below.
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (result.isFailure()) {
if (result.getResponse() == IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
mIsPremium = true;
mAdView.setVisibility(View.GONE);
removebutton.setText("PURCHASED");
Snackbar.make(findViewById(R.id.container2), "Purchased", Snackbar.LENGTH_LONG)
.setAction("UNDO", mOnClickListener)
.setActionTextColor(Color.parseColor("#FFAB40"))
.setDuration(4000).show();
}
} else if (purchase.getSku().equals(ITEM_SKU)) {
mIsPremium = true;
mAdView.setVisibility(View.GONE);
removebutton.setText("PURCHASED");
Snackbar.make(findViewById(R.id.container2), "Ads have been removed", Snackbar.LENGTH_LONG)
.setAction("UNDO", mOnClickListener)
.setActionTextColor(Color.parseColor("#FFAB40"))
.setDuration(4000)
.show();
}
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
}
};
}
};