fix init app not found id,change ffi from MainActivity to MainService,add boot service but not open

This commit is contained in:
csf
2022-02-09 17:04:13 +08:00
parent 2137f4b3f2
commit 9c3b10d6a9
9 changed files with 191 additions and 95 deletions
@@ -0,0 +1,24 @@
package com.carriez.flutter_hbb
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build
import android.widget.Toast
// 开机自启动 此功能暂不开启
class BootReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if ("android.intent.action.BOOT_COMPLETED" == intent.action){
val it = Intent(context,MainService::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
Toast.makeText(context, "RustDesk is Open", Toast.LENGTH_LONG).show();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(it)
}else{
context.startService(it)
}
}
}
}