Skip to content

AmosKorir/Lipa-Na-Mpesa-Android-Widget

Repository files navigation

Lipa-Na-Mpesa-Android-Widget

Floating Lipa na Mpesa Widget Download

This a simple android library that helps to create a floating widget with mpesa payment details or any payment gateway that has the same payment format. This offers great user experience when making payment manually. The user should not cram the payment details, the widget floats in all the screens and the can click and copy the details they need.

How to use

Gradle:

 implementation 'com.lipanampesa:LipaNaMpesa:0.1.1'

Ask for permission to show a floating widget.

 //ask for permission
 private fun askPermission() {
   val intent = Intent(
     Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
     Uri.parse("package:$packageName")
   )
   ActivityCompat.startActivityForResult(
     this,
     intent,
     LipaNaMpesaConstants.SYSTEM_ALERT_WINDOW_PERMISSION,
     null
   )
 }

Show the widget. a Full example

 var intent = Intent(this@MainActivity, FloatingService::class.java)
      var lipaNaMpesa =
        LipaNaMpesa(
          "34545455",
          "0712345678",
          "2000"
        )
      intent.putExtra(LipaNaMpesaConstants.LIPANAMPESA, lipaNaMpesa)
      startService(intent)