|
|
@@ -1,5 +1,6 @@
|
|
|
package com.jiuyan.sheep_children.floatwindow;
|
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.app.ActivityManager;
|
|
|
import android.app.Service;
|
|
|
import android.app.usage.UsageEvents;
|
|
|
@@ -27,6 +28,7 @@ import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.jiuyan.sheep_children.R;
|
|
|
+import com.jiuyan.sheep_children.SheepApp;
|
|
|
import com.jiuyan.sheep_children.event.FloatMsg;
|
|
|
import com.jiuyan.sheep_children.page.MainActivity;
|
|
|
import com.jiuyan.sheep_children.page.ShotScreenActivity;
|
|
|
@@ -40,6 +42,7 @@ import org.greenrobot.eventbus.Subscribe;
|
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
public class FloatService extends Service implements View.OnClickListener {
|
|
|
@@ -91,7 +94,7 @@ public class FloatService extends Service implements View.OnClickListener {
|
|
|
|
|
|
//设置悬浮窗口长宽数据.
|
|
|
params.width = -2;
|
|
|
- params.height = DeviceInfo.dip2px(this,40f);
|
|
|
+ params.height = DeviceInfo.dip2px(this, 40f);
|
|
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(getApplication());
|
|
|
//获取浮动窗口视图所在布局.
|
|
|
@@ -167,7 +170,8 @@ public class FloatService extends Service implements View.OnClickListener {
|
|
|
case R.id.img_commit_right:
|
|
|
mLeft.setVisibility(View.GONE);
|
|
|
mRight.setVisibility(View.GONE);
|
|
|
- String pkg = PackageUtil.getLauncherTopApp(FloatService.this);
|
|
|
+ closeActivitys();
|
|
|
+ String pkg = PackageUtil.getLauncherTopApp(getApplicationContext());
|
|
|
intent = new Intent(FloatService.this, ShotScreenActivity.class);
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
intent.putExtra("pkg", pkg);
|
|
|
@@ -203,6 +207,12 @@ public class FloatService extends Service implements View.OnClickListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void closeActivitys() {
|
|
|
+ for (Map.Entry<String, Activity> entry : SheepApp.mActivitys.entrySet()) {
|
|
|
+ entry.getValue().finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void onMessageEvent(FloatMsg event) {
|