How to redirect to landing page if "Subscription" is acknowledged in Android

72 views Asked by At
if(!purchase.isAcknowledged()){
                AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
                        .setPurchaseToken(purchase.getPurchaseToken())
                        .build();
                billingClient.acknowledgePurchase(acknowledgePurchaseParams,acknowledgePurchaseResponseListener);
                binding.tvSubsts.setText("Subscribed");
                isSuccess=true;

When subscription payment is successful it will redirect to the landing page which is the contents of the application, whether in ListView or BottomView.

1

There are 1 answers

2
TIMBLOCKER On

You could alter your Code as follows:

if(!purchase.isAcknowledged()){
            AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
                    .setPurchaseToken(purchase.getPurchaseToken())
                    .build();
            billingClient.acknowledgePurchase(acknowledgePurchaseParams,acknowledgePurchaseResponseListener);
            binding.tvSubsts.setText("Subscribed");
            isSuccess=true;

            //Transition to your Activity
            Intent intent = new Intent(getApplicationContext(), YourActivity.class);

            //pass data if needed
            intent.putExtra("EXTRA_SESSION_ID", sessionId);

            startActivity(intent);}

In your DestinationActivity you can do the following to recieve the Information:

String sessionId = getIntent().getStringExtra("EXTRA_SESSION_ID");

Here you can show all details that the Subsciption in AcknowledgePurchaseParams has to the user.