| | |
| | | import android.content.BroadcastReceiver |
| | | import android.content.Context |
| | | import android.content.Intent |
| | | import android.os.Handler |
| | | import android.os.Looper |
| | | import cn.sinata.xldutils.utils.toast |
| | | import com.okgoincar.slab.SlabLoginActivity |
| | | import com.okgoincar.utils.Cache.CacheUtil |
| | | import org.greenrobot.eventbus.EventBus |
| | | import org.jetbrains.anko.startActivity |
| | | |
| | | class MainBroadCastReceiver : BroadcastReceiver() { |
| | | override fun onReceive(context: Context?, intent: Intent?) { |
| | | toast("获取的action="+intent!!.getStringExtra("isLogin")) |
| | | toast("收到广播1") |
| | | Handler(Looper.getMainLooper()).post { |
| | | val b = intent!!.getBooleanExtra("isLogin",false) |
| | | val driverName = intent!!.getStringExtra("driverName") |
| | | toast("司机名字=$driverName") |
| | | if (!b){ |
| | | toast("LED退出登录") |
| | | CacheUtil.get().clear() |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP)) |
| | | // context?.startActivity<SlabLoginActivity>() |
| | | }else{ |
| | | toast("开始登录") |
| | | } |
| | | var heay = intent.getBooleanExtra("isHeavy",false) |
| | | toast("获取的网约=$heay") //顶灯 |
| | | var price = intent.getDoubleExtra("price",0.0) |
| | | toast("收到的显示价格$price") |
| | | var mileage = intent.getDoubleExtra("mileage",0.0) |
| | | toast("收到的显示价格$mileage") |
| | | } |
| | | } |
| | | } |