セキュリティのため、USB Debuggingモードの場合に起動を拒否する必要があり実装しました。
最初に起動するActivity内に記載します。
@AndroidEntryPoint
class SomeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (isDebuggingMode()) {
restrictOperation()
}
}
private fun isDebuggingMode (): Boolean = false
Settings.Secure.getInt(
contentResolver,
Settings.Secure.ADB_ENABLED, 0) != 0
private fun restrictOperation () {
AlertDialog.Builder(this)
.setTitle("USBデバックをOFFにしてください")
.setMessage("ご利用の端末はUSBデバックがONになっているため、ご利用いただけません。")
.setCancelable(false)
.setPositiveButton("OK") { _, _ ->
finish()
}
.show()
}