|
|
@@ -80,6 +80,8 @@ import android.widget.CheckBox;
|
|
|
import android.os.Build;
|
|
|
import java.util.ArrayList;
|
|
|
import com.blankj.utilcode.util.NetworkUtils;
|
|
|
+import android.view.Window;
|
|
|
+import android.view.WindowManager;
|
|
|
|
|
|
|
|
|
public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCallbacks, SensorEventListener {
|
|
|
@@ -124,6 +126,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
|
|
|
static final int GOT_REMOTE_LOG_PROCEDURE_START = 10;
|
|
|
|
|
|
private static final String LOG_TAG = "TelephonyManagerSub";
|
|
|
+ private static final boolean DISABLE_BG_RUNNING = true;
|
|
|
|
|
|
Handler mainHandler = new Handler(new Handler.Callback() {
|
|
|
@Override
|
|
|
@@ -247,6 +250,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
Log.e(LOG_TAG,"手机SDK版本:"+Build.VERSION.SDK_INT);
|
|
|
XXPermissions xXPermissions = XXPermissions.with(this);
|
|
|
xXPermissions.permission(Permission.MANAGE_EXTERNAL_STORAGE);
|
|
|
@@ -670,12 +674,22 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
|
|
|
@Override
|
|
|
protected void onPause() {
|
|
|
super.onPause();
|
|
|
- Log.e(LOG_TAG,"onPause "+first_time);
|
|
|
+ Log.e(LOG_TAG,"onPause "+first_time +" result_of_Rotation "+result_of_Rotation);
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
|
|
|
if (serviceBound) {
|
|
|
scrcpy.pause();
|
|
|
}
|
|
|
+
|
|
|
+ //禁止后台运行
|
|
|
+ if(DISABLE_BG_RUNNING && !result_of_Rotation){
|
|
|
+ if (serviceBound) {
|
|
|
+ scrcpy.StopService();
|
|
|
+ unbindService(serviceConnection);
|
|
|
+ }
|
|
|
+ android.os.Process.killProcess(android.os.Process.myPid());
|
|
|
+ System.exit(1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|