Hgidi
Hgidi
Activity
import android.app.AlertDialog
import android.content.Context
import android.net.wifi.WifiManager
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import java.util.Timer
import java.util.TimerTask
wifiManager = applicationContext.getSystemService(Context.WIFI_SERVICE) as
WifiManager
deviceListLayout = findViewById(R.id.deviceListLayout)
scanButton = findViewById(R.id.scanButton)
scanButton.setOnClickListener {
scanDevices()
}
if (connectedDevices.isEmpty()) {
Toast.makeText(this, "No devices found", Toast.LENGTH_SHORT).show()
return
}
deviceName.text = device
setLimitButton.setOnClickListener {
showTimeLimitDialog(device)
}
deviceListLayout.addView(deviceView)
}
applyButton.setOnClickListener {
val timeLimit = timeLimitInput.text.toString().toIntOrNull()
if (timeLimit != null && timeLimit > 0) {
setTimeLimit(device, timeLimit)
dialog.dismiss()
} else {
Toast.makeText(this, "Invalid time limit",
Toast.LENGTH_SHORT).show()
}
}
dialog.show()
}