diff --git a/app/src/main/java/com/bell/floatlayoutdemo/Main2Service.java b/app/src/main/java/com/bell/floatlayoutdemo/Main2Service.java index b722d48..0c608ac 100644 --- a/app/src/main/java/com/bell/floatlayoutdemo/Main2Service.java +++ b/app/src/main/java/com/bell/floatlayoutdemo/Main2Service.java @@ -28,7 +28,7 @@ public class Main2Service extends Service implements View.OnClickListener, View.OnTouchListener { private static final String TAG = "Main2Service"; - + Intent myIntent; RelativeLayout baseLayout; WindowManager.LayoutParams params; WindowManager windowManager; @@ -45,6 +45,7 @@ //不与Activity进行绑定. @Override public IBinder onBind(Intent intent) { + myIntent = intent; return null; } @@ -93,6 +94,7 @@ baseLayout.findViewById(R.id.btn).setOnClickListener(this); baseLayout.findViewById(R.id.reset).setOnClickListener(this); + baseLayout.findViewById(R.id.channel).setOnClickListener(this); f1 = baseLayout.findViewById(R.id.img1); f1.setOnTouchListener(this); @@ -117,25 +119,7 @@ } } }); -/* - baseLayout.findViewById(R.id.float_300).setOnClickListener(this); - baseLayout.findViewById(R.id.float_400).setOnClickListener(this); - baseLayout.findViewById(R.id.float_500).setOnClickListener(this); - baseLayout.findViewById(R.id.float_600).setOnClickListener(this); - baseLayout.findViewById(R.id.float_700).setOnClickListener(this); - baseLayout.findViewById(R.id.float_800).setOnClickListener(this); - baseLayout.findViewById(R.id.float_900).setOnClickListener(this); - baseLayout.findViewById(R.id.float_200).setOnClickListener(this); -*/ - /*imageButton1.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - params.x = (int) event.getRawX() - 150; - params.y = (int) event.getRawY() - 150 - statusBarHeight; - windowManager.updateViewLayout(toucherLayout,params); - return false; - } - });*/ + } @Override @@ -156,10 +140,17 @@ f2.setX(0); f2.setY(0); break; + + case R.id.channel: + Intent intent = new Intent(this, MainService.class); + startService(intent); + stopSelf(); + break; } } + public String getShellStr(int m) { int r1 = getRandomInt(); int x1 = 700 + r1;