Instabug-Android icon indicating copy to clipboard operation
Instabug-Android copied to clipboard

App restart required to apply Instabug InvocationEvents

Open muralijoyn opened this issue 3 years ago • 0 comments

Steps to Reproduce the Problem

Enable:

  1. Enable Instabug with InvocationEvents --> InstabugInvocationEvent.SHAKE, InstabugInvocationEvent.SCREENSHOT
  2. and shake the device without restarting the device and observe bug-report pop-up won't show
  3. shake the device after restarting the app bug-report pop-up will show.

Disable

  1. Disable Instabug with InvocationEvents --> InstabugInvocationEvent.NONE
  2. shake the device without restarting the app, a bug report pop-up will show.
  3. and shake the device after restarting the device and observe bug-report pop-up won't show

Expected Behavior

  1. Changes should apply without restarting the app.

Actual Behavior

  1. App restart is required to apply Instabug InvocationEvents

Instabug integration code

package com.test.instabugtest

import android.app.Application
import android.content.Context
import android.content.SharedPreferences
import androidx.core.content.edit
import com.instabug.library.Instabug
import com.instabug.library.invocation.InstabugInvocationEvent

const val KEY_INSTABUG = "Instabug"

class InstabugConfig(
    private val context: Application,
) {
    private val sharedPreferences: SharedPreferences =
        context.getSharedPreferences(this::class.java.simpleName, Context.MODE_PRIVATE)

    var isEnabled
          set(value) {
                sharedPreferences.edit {
                       putBoolean(KEY_INSTABUG, value).commit()
                }
           }
          get() = sharedPreferences.getBoolean(KEY_INSTABUG, false)
    

    fun enable(enable: Boolean) {
            val invocationEvent = if (enable) {
                InstabugInvocationEvent.SHAKE
           } else {
                InstabugInvocationEvent.NONE
           }

           Instabug.Builder(context, context.getString(R.string.instabug_beta_id))
                .setInvocationEvents(invocationEvent)
                .build()

            isEnabled = enable
        }

}
//Activity
val config = InstabugConfig(this.application)
buttonEnable.setOnClickListener {
      config?.enable( true)
}

buttonDisable.setOnClickListener {
        config?.enable( false)
}

SDK Version

implementation 'com.instabug.library:instabug:11.5.1'

Android Version

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.test.instabugtest"
        minSdk 23
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
 ......
}

Device Model

Samsung S21 Ultra (Android 12)

[Optional] Project That Reproduces the Issue

muralijoyn avatar Oct 14 '22 09:10 muralijoyn