Home > database >  How do I write it in Kotlin
How do I write it in Kotlin

Time:09-30

I am a beginner in android and also in kotlin.

can anyone tell me how to write the below code in Kotlin.

public class MainActivity extends AppCompatActivity implements Instamojo.InstamojoPaymentCallback {
    ...
    
    @Override
    public void onInstamojoPaymentComplete(String orderID, String transactionID, String paymentID, String paymentStatus) {
        ...
    }

    @Override
    public void onPaymentCancelled() {
        ...
    }

    @Override
    public void onInitiatePaymentFailure(String errorMessage) {
        ...
    }
}

Thankyou.

CodePudding user response:

enter image description here

From the left-hand side Option menu, select Android Project and right-click on the source code file. Select the option “Convert Java File to Kotlin File”. One can also use the shortcut command “Ctrl Alt Shift K” while the file is opened in Android Studio. reference

Your Code :

class MainActivity : AppCompatActivity(), Instamojo.InstamojoPaymentCallback {
   override fun onInstamojoPaymentComplete(
        orderID: String?,
        transactionID: String?,
        paymentID: String?,
        paymentStatus: String?
    ) {
       ...
    }

    override fun onPaymentCancelled() {
        ...
        
    }
    override fun onInitiatePaymentFailure(errorMessage: String?) {
        ...
        
    }
}
  • Related