[Feat]添加杀死App功能
This commit is contained in:
@@ -2,10 +2,11 @@ package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Process
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
@@ -29,6 +30,7 @@ import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.view_auto_pilot_check.view.*
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* @author ChenFufeng
|
||||
@@ -97,6 +99,9 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
ivCloseIcon.setOnClickListener {
|
||||
clickListener?.onClose(it)
|
||||
}
|
||||
rlKillLayout.setOnClickListener {
|
||||
killApp()
|
||||
}
|
||||
viewCheckStatus.setOnClickListener {
|
||||
clickListener?.go2CheckPage()
|
||||
}
|
||||
@@ -170,6 +175,16 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun killApp() {
|
||||
Intent(Intent.ACTION_MAIN).apply {
|
||||
addCategory(Intent.CATEGORY_HOME)
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
context.startActivity(this)
|
||||
Process.killProcess(Process.myPid())
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class MogoMainService extends Service implements IMogoLocationListener {
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return START_STICKY;
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
private void initAndStartLocation() {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -107,6 +107,31 @@
|
||||
android:textSize="32px" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlKillLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="142px">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivKillImg"
|
||||
android:layout_width="150px"
|
||||
android:layout_height="150px"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/close_nor" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvKillContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="42px"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="23px"
|
||||
android:text="杀死APP"
|
||||
android:textColor="@color/color_FFA7B6F0"
|
||||
android:textSize="32px" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
||||
Reference in New Issue
Block a user