अंततः मुझे उपरोक्त समस्या का समाधान मिला। ऑनविंडो फोकस चेंज मैंने सिस्टम जेनरेट किए गए डायलॉग को बंद कर दिया और मेरी समस्या हल हो गई। नीचे नमूना कोड है।
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus)
{// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
अद्यतन:
मोबाइल में स्थिति पट्टी जो रास्ता नीचे स्क्रीन उपयोग पर नीचे स्वाइप पर प्रकट ब्लॉक करने के लिए।
private Handler collapseNotificationHandler;
@Override
public void onWindowFocusChanged(boolean hasFocus) {
boolean currentFocus = hasFocus;
if (!hasFocus) {
collapseNow(true,currentFocus);
}
}
public void collapseNow(final boolean shouldCollapse, final boolean currentFocus) {
// Initialize 'collapseNotificationHandler'
if (collapseNotificationHandler == null) {
collapseNotificationHandler = new Handler();
}
// If window focus has been lost && activity is not in a paused state
// Its a valid check because showing of notification panel
// steals the focus from current activity's window, but does not
// 'pause' the activity
if (!currentFocus && !isPaused) {
// Post a Runnable with some delay - currently set to 50 ms
collapseNotificationHandler.postDelayed(new Runnable() {
@Override
public void run() {
// Use reflection to trigger a method from 'StatusBarManager'
Object statusBarService = getSystemService("statusbar");
Class<?> statusBarManager = null;
try {
statusBarManager = Class.forName("android.app.StatusBarManager");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Method collapseStatusBar = null;
try {
// Prior to API 17, the method to call is 'collapse()'
// API 17 onwards, the method to call is `collapsePanels()`
if (Build.VERSION.SDK_INT > 16) {
collapseStatusBar = statusBarManager.getMethod("collapsePanels");
} else {
collapseStatusBar = statusBarManager.getMethod("collapse");
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
collapseStatusBar.setAccessible(shouldCollapse);
try {
collapseStatusBar.invoke(statusBarService);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
// Check if the window focus has been returned
// If it hasn't been returned, post this Runnable again
// Currently, the delay is 50 ms. You can change this
// value to suit your needs.
if (!currentFocus && !isPaused) {
collapseNotificationHandler.postDelayed(this, 50);
}
}
}, 0);
}
}
"isPaused" बूलियन जो ऐप रोकता है जब ऐप रोकता है।
स्रोत
2015-11-17 18:34:05
क्या आपको लॉलीपॉप में हालिया कार्य मिलते हैं? क्योंकि यह आपके लिए भी एक समस्या होगी, मैं पहले से ही इस तरह की स्थिति से गुजर चुका हूं। – Androider
@Androider जो कोई समस्या नहीं है। मैं सेटिंग विकल्प की तलाश में हूं। यह निश्चित रूप से निश्चित ऐप में अक्षम है। क्या आपको इसके बारे में कोई जानकारी है? –
सिस्टम बार – Androider