Skip to content Skip to sidebar Skip to footer

Initialize Paypal Library Only Once For Multiple Activities

I'm using the PayPal MECL library to: Display the 'Pay with PayPal'-button in Activity A Initiate the payment process in Activity B For obvious reasons, I don't want to initializ

Solution 1:

Make a base activity and extend it to other activity.

Inside base activity, write the code for initializing paypal process or whatever you want to do.

publicclassBaseActivityextendsActivity {
 .....
 .....
 .....
}

publicclassActivityAextendsBaseActivity {
 .....
 .....
 .....

}

Solution 2:

use singleton claas, in the constructor of the Class you can initialize paypal library , and can use it whenever and wherever want, it wont initialize again,

singleton doc

Solution 3:

I ended up declaring a class that extends Application, where I initialize the library once and from which it can be used by all activities.

Post a Comment for "Initialize Paypal Library Only Once For Multiple Activities"