Skip to content

Commit 3211f9a

Browse files
authored
Merge pull request #4 from nbschultz97/codex/add-stopscan-method-and-override-ondestroy
2 parents 7e4f838 + 85bfb00 commit 3211f9a

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Generated binary assets
2-
app/
32
__pycache__/
43
gradle/wrapper/gradle-wrapper.jar
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.example.dronedetect
2+
3+
import android.content.BroadcastReceiver
4+
import android.content.Context
5+
import android.content.Intent
6+
import android.net.wifi.WifiManager
7+
import android.os.Handler
8+
import android.os.Looper
9+
10+
class DroneSignalDetector(private val context: Context) {
11+
private val handler = Handler(Looper.getMainLooper())
12+
private val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
13+
private val receiver = WifiScanReceiver()
14+
15+
fun startScan() {
16+
// TODO: implement scanning logic
17+
}
18+
19+
fun stopScan() {
20+
handler.removeCallbacksAndMessages(null)
21+
context.unregisterReceiver(receiver)
22+
}
23+
}
24+
25+
class WifiScanReceiver : BroadcastReceiver() {
26+
override fun onReceive(context: Context?, intent: Intent?) {
27+
// TODO: handle scan results
28+
}
29+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.example.dronedetect
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
6+
class MainActivity : AppCompatActivity() {
7+
private lateinit var detector: DroneSignalDetector
8+
9+
override fun onCreate(savedInstanceState: Bundle?) {
10+
super.onCreate(savedInstanceState)
11+
detector = DroneSignalDetector(this)
12+
}
13+
14+
override fun onDestroy() {
15+
super.onDestroy()
16+
detector.stopScan()
17+
}
18+
}

0 commit comments

Comments
 (0)