Android一次完美的跨进程服务共享实践

override fun onBind(intent: Intent?): IBinder? {

return mBinder

}

@Synchronized

private fun startRecordingInternal(recorderConfig: RecorderConfig) {

val willStartRecorderResult =

RecorderResultBuilder.aRecorderResult().withRecorderFile(recorderConfig.recorderFile)

.withRecorderId(recorderConfig.recorderId).build()

if (ContextCompat.checkSelfPermission(

this@RecorderService,

android.Manifest.permission.RECORD_AUDIO

)

!= PackageManager.PERMISSION_GRANTED

) {

logD(“Record audio permission not granted, can’t record”)

notifyCallBack {

it.onException(

“Record audio permission not granted, can’t record”,

willStartRecorderResult

)

}

return

}

if (ContextCompat.checkSelfPermission(

this@RecorderService,

android.Manifest.permission.WRITE_EXTERNAL_STORAGE

)

!= PackageManager.PERMISSION_GRANTED

) {

logD(“External storage permission not granted, can’t save recorded”)

notifyCallBack {

it.onException(

“External storage permission not granted, can’t save recorded”,

willStartRecorderResult

)

}

return

}

if (isRecording()) {

val weight = recorderConfig.weight

if (weight < currentWeight) {

logD(“Recording with weight greater than in recording”)

notifyCallBack {

it.onException(

“Recording with weight greater than in recording”,

willStartRecorderResult

)

}

return

}

if (weight > currentWeight) {

//只要权重大于当前权重,立即停止当前。

stopRecordingInternal()

}

if (weight == currentWeight) {

if (recorderConfig.recorderId == currentRecorderResult.recorderId) {

<
  • 22
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值