StandOutWindow 라이브러리를 사용하고 있습니다. 설정 화면에서 스위치가 켜져 있습니다 (켜기/끄기). 스위치를 켜면 팝업과 알림이 표시됩니다. 스위치를 끄면 팝업이 표시되지 않습니다. 알림을 클릭하면 팝업이 숨겨지고 스위치가 "꺼짐"상태가됩니다. 이제 팝업 만 숨겨집니다. 스위치는 또한 "ON"상태입니다. 스위치를 끌 수있는 방법. getPersistentNotificationIntent
에 코드를 쓰려고했지만 시도 할 수 없습니다.StandOutWindow android에서 이벤트 닫기 알림을 받습니까?
public class TogglePopup extends StandOutWindow {
public View view;
@Override
public String getAppName() {
return "JSDict";
}
@Override
public int getAppIcon() {
return android.R.drawable.ic_menu_close_clear_cancel;
}
@SuppressLint("NewApi")
@Override
public void createAndAttachView(int id, final FrameLayout frame) {
// create a new layout from body.xml
final LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.popup_toggle, frame, true);
ToggleButton toggle = (ToggleButton) view
.findViewById(R.id.toggle_popup);
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
LinearLayout viewLinear = (LinearLayout) view
.findViewById(R.id.toggle_popup_background);
if (isChecked) {
// The toggle is enabled
viewLinear
.setBackgroundResource(R.drawable.popup_toggle_on);
ComponentName service = getApplicationContext()
.startService(
new Intent(getApplicationContext(),
ClipboardMonitor.class));
StandOutWindow.closeAll(getApplicationContext(),
ClipboardMonitor.class);
StandOutWindow.show(getApplicationContext(),
ClipboardMonitor.class, StandOutWindow.DEFAULT_ID);
} else {
// The toggle is disabled
viewLinear
.setBackgroundResource(R.drawable.popup_toggle_off);
getApplicationContext().stopService(
new Intent(getApplicationContext(),
ClipboardMonitor.class));
StandOutWindow.closeAll(getApplicationContext(),
ClipboardMonitor.class);
}
}
});
}
// the window will be centered
@Override
public StandOutLayoutParams getParams(int id, Window window) {
return new StandOutLayoutParams(id, 250, 300,
StandOutLayoutParams.CENTER, StandOutLayoutParams.CENTER);
}
// move the window by dragging the view
@Override
public int getFlags(int id) {
return super.getFlags(id) | StandOutFlags.FLAG_BODY_MOVE_ENABLE
| StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE;
}
@Override
public String getPersistentNotificationMessage(int id) {
return "Click to close the JSDict";
}
@Override
public Intent getPersistentNotificationIntent(int id) {
return StandOutWindow.getCloseIntent(this, TogglePopup.class, id);
/*
* StandOutWindow.show(this, WidgetsWindow.class,
* StandOutWindow.DEFAULT_ID);
*/
}
}