71 lines
2.5 KiB
Kotlin
71 lines
2.5 KiB
Kotlin
package com.example.oilcheckkotlin
|
|
|
|
import android.app.Notification
|
|
import android.app.PendingIntent
|
|
import android.content.Intent
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import android.os.Bundle
|
|
import android.util.Log
|
|
import android.widget.Button
|
|
import com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator
|
|
import com.luckycatlabs.sunrisesunset.dto.Location
|
|
import java.util.Calendar
|
|
|
|
class MainActivity : AppCompatActivity() {
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_main)
|
|
|
|
findViewById<Button>(R.id.btnStop)
|
|
.setOnClickListener{
|
|
Log.d("Debug", "stop clicked")
|
|
val intent = Intent(this, BLEConnectionService::class.java)
|
|
.setAction("STOPService")
|
|
startService(intent)
|
|
}
|
|
findViewById<Button>(R.id.btnToggle)
|
|
.setOnClickListener {
|
|
Log.d("Debug", "Button Toggle")
|
|
val intent = Intent(this, BLEConnectionService::class.java)
|
|
.setAction("Toggle")
|
|
startService(intent)
|
|
}
|
|
findViewById<Button>(R.id.btnOTA)
|
|
.setOnClickListener{
|
|
val intent = Intent(this, BLEConnectionService::class.java)
|
|
.setAction("OTA")
|
|
startService(intent)
|
|
|
|
}
|
|
findViewById<Button>(R.id.btn_1km)
|
|
.setOnClickListener{
|
|
val intent = Intent(this, BLEConnectionService::class.java)
|
|
.setAction("X")
|
|
startService(intent)
|
|
}
|
|
findViewById<Button>(R.id.btn_500m)
|
|
.setOnClickListener{
|
|
val intent = Intent(this, BLEConnectionService::class.java)
|
|
.setAction("XX")
|
|
startService(intent)
|
|
}
|
|
findViewById<Button>(R.id.btn_300m)
|
|
.setOnClickListener{
|
|
val intent = Intent(this, BLEConnectionService::class.java)
|
|
.setAction("XXX")
|
|
startService(intent)
|
|
}
|
|
findViewById<Button>(R.id.btn_150m)
|
|
.setOnClickListener{
|
|
val intent = Intent(this, BLEConnectionService::class.java)
|
|
.setAction("XXXX")
|
|
startService(intent)
|
|
}
|
|
|
|
startForegroundService(
|
|
Intent(this, BLEConnectionService::class.java)
|
|
.setAction("STARTService")
|
|
)
|
|
}
|
|
} |