Java Code Examples for android.content.Intent#ACTION_CLOSE_SYSTEM_DIALOGS

The following examples show how to use android.content.Intent#ACTION_CLOSE_SYSTEM_DIALOGS . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Noyze   File: AudioHelper.java    License: Apache License 2.0 6 votes vote down vote up
public void closeSystemDialogs(Context context, String reason) {
    LOGI(TAG, "closeSystemDialogs(" + reason + ')');
    IInterface wm = PopupWindowManager.getIWindowManager();
    try {
        if (null == wmCsd)
            wmCsd = wm.getClass().getDeclaredMethod("closeSystemDialogs", String.class);
        if (null != wmCsd) {
            wmCsd.setAccessible(true);
            wmCsd.invoke(wm, reason);
            return;
        }
    } catch (Throwable t) {
        LOGE(TAG, "Could not invoke IWindowManager#closeSystemDialogs");
    }

    // Backup is to send the intent ourselves.
    Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    intent.putExtra("reason", reason);
    context.sendBroadcast(intent);
}
 
Example 2
Source Project: buyingtime-android   File: AlarmReceiver.java    License: MIT License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

    String guid = intent.getStringExtra("ALARM_GUID");
    Alarm alarm = Alarms.getCurrent().getByGuid(guid);
    if (alarm==null) return;


    PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "BUYINGTIMEALARM");
    wl.acquire(30000);

    // Close dialogs and window shade
    Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    context.sendBroadcast(closeDialogs);
    AlarmHelper.getCurrent().showAlert(context, alarm);

}
 
Example 3
Source Project: NotifyMe   File: ActionReceiver.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String notificationId = intent.getStringExtra("_id");
    String rrule = intent.getStringExtra("rrule");
    long dstart = intent.getLongExtra("dstart",Calendar.getInstance().getTimeInMillis());
    int index = intent.getIntExtra("index",-1);
    String action = intent.getStringExtra("action");
    try {
        Intent tent = Intent.parseUri(action, 0);
        context.startActivity(tent);
    }catch (Exception e){
        e.printStackTrace();
    }

    if(intent.getBooleanExtra("collapse",true)) {
        Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        context.sendBroadcast(it);
    }

    if(intent.getBooleanExtra("dismiss",true)){
        DeletePendingIntent.DeleteNotification(context,notificationId,rrule,dstart);
        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.cancel(Integer.parseInt(notificationId));
    }
}
 
Example 4
/** Starts the Settings Activity if connection settings are missing
 *
 * @return true if setup was started
 */
private boolean startSetupIfNeeded(){
    Preferences preferences = new Preferences(getApplicationContext());
    if (TextUtils.isEmpty(preferences.getString(R.string.pref_key_host, null)) || preferences.getInt(R.string.pref_key_port, -1) == -1){
        Intent settingsIntent = new Intent(this, SettingsActivity.class);
        settingsIntent.putExtra(SettingsActivity.EXTRA_SHOW_TOAST_KEY, SettingsActivity.EXTRA_SHOW_TOAST_SETUP_REQUIRED_FOR_QUICK_TILE);
        settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        // Use TaskStackBuilder to make sure the MainActivity opens when the SettingsActivity is closed
        TaskStackBuilder.create(this)
                .addNextIntentWithParentStack(settingsIntent)
                .startActivities();

        Intent closeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        sendBroadcast(closeIntent);

        return true;
    }

    return false;
}
 
Example 5
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(0, 0);

    //PPApplication.logE("RestartEventsFromGUIActivity.onCreate", "xxx");

    if (showNotStartedToast()) {
        finish();
        return;
    }

    activityStarted = true;

    // close notification drawer - broadcast pending intent not close it :-/
    Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    sendBroadcast(it);

    dataWrapper = new DataWrapper(getApplicationContext(), false, 0, false);
}
 
Example 6
@Override
    public void onClick() {
        super.onClick();
        if (DEBUG) {
            MyLog.i(CLS_NAME, "onClick");
        }

        final LocalRequest lr = new LocalRequest(getApplicationContext());
        lr.prepareIntro();
        lr.execute();

        final Intent closeShadeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        sendBroadcast(closeShadeIntent);

//        final Intent preferenceIntent = new Intent(getApplicationContext(), ActivityTilePreferences.class);
//        startActivityAndCollapse(preferenceIntent);
    }
 
Example 7
Source Project: MobileGuard   File: LockedActivity.java    License: MIT License 6 votes vote down vote up
/**
 * 3
 */
@Override
protected void initEvent() {
    // set on click listener
    findViewById(R.id.btn_ok).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onOk();
        }
    });

    // register broadcast to receiver the HOME key down
    IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    receiver = new HomeKeyDownReceiver();
    registerReceiver(receiver, filter);
}
 
Example 8
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case "prev":
            FlutterMediaNotificationPlugin.callEvent("prev");
            break;
        case "next":
            FlutterMediaNotificationPlugin.callEvent("next");
            break;
        case "toggle":
            String title = intent.getStringExtra("title");
            String author = intent.getStringExtra("author");
            boolean play = intent.getBooleanExtra("play",true);

            if(play)
                FlutterMediaNotificationPlugin.callEvent("play");
            else
                FlutterMediaNotificationPlugin.callEvent("pause");

            FlutterMediaNotificationPlugin.showNotification(title, author,play);
            break;
        case "select":
            Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            context.sendBroadcast(closeDialog);
            String packageName = context.getPackageName();
            PackageManager pm = context.getPackageManager();
            Intent launchIntent = pm.getLaunchIntentForPackage(packageName);
            context.startActivity(launchIntent);

            FlutterMediaNotificationPlugin.callEvent("select");
    }
}
 
Example 9
public DreamController(Context context, Handler handler, Listener listener) {
    mContext = context;
    mHandler = handler;
    mListener = listener;
    mIWindowManager = WindowManagerGlobal.getWindowManagerService();
    mCloseNotificationShadeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    mCloseNotificationShadeIntent.putExtra("reason", "dream");
}
 
Example 10
Source Project: android-kiosk-mode   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 11
Source Project: imsdk-android   File: IMBaseActivity.java    License: MIT License 5 votes vote down vote up
private void registerHomeKeyReceiver(Context context) {
    LogUtil.i("Home Reg", "registerHomeKeyReceiver");
    mHomeKeyReceiver = new HomeWatcherReceiver();
    final IntentFilter homeFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);

    context.registerReceiver(mHomeKeyReceiver, homeFilter);
}
 
Example 12
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case "prev":
            MediaNotificationPlugin.callEvent("prev");
            break;
        case "next":
            MediaNotificationPlugin.callEvent("next");
            break;
        case "toggle":
            String title = intent.getStringExtra("title");
            String author = intent.getStringExtra("author");
            String action = intent.getStringExtra("action");

            MediaNotificationPlugin.show(title, author, action.equals("play"));
            MediaNotificationPlugin.callEvent(action);
            break;
        case "select":
            Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            context.sendBroadcast(closeDialog);
            String packageName = context.getPackageName();
            PackageManager pm = context.getPackageManager();
            Intent launchIntent = pm.getLaunchIntentForPackage(packageName);
            context.startActivity(launchIntent);

            MediaNotificationPlugin.callEvent("select");
    }
}
 
Example 13
Source Project: SystemUITuner2   File: BatteryTileService.java    License: MIT License 5 votes vote down vote up
@Override
public void onClick() {
    Intent intentBatteryUsage = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
    startActivity(intentBatteryUsage);

    Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    sendBroadcast(it);
}
 
Example 14
@Override public void onReceive(Context context, Intent intent) {
  notificationPublishRelay =
      ((AptoideApplication) context.getApplicationContext()).getNotificationsPublishRelay();
  Bundle intentExtras = intent.getExtras();
  NotificationInfo notificationInfo;
  NotificationManager manager =
      (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
  Intent closeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);

  switch (intent.getAction()) {
    case Intent.ACTION_BOOT_COMPLETED:
      notificationInfo = new NotificationInfo(Intent.ACTION_BOOT_COMPLETED);
      notificationPublishRelay.call(notificationInfo);
      break;
    case NOTIFICATION_PRESSED_ACTION:
      notificationInfo = new NotificationInfo(NOTIFICATION_PRESSED_ACTION,
          intentExtras.getInt(NOTIFICATION_NOTIFICATION_ID),
          intentExtras.getString(NOTIFICATION_TRACK_URL),
          intentExtras.getString(NOTIFICATION_TARGET_URL));
      manager.cancel(intent.getIntExtra(NOTIFICATION_NOTIFICATION_ID, -1));
      context.sendBroadcast(closeIntent);
      notificationPublishRelay.call(notificationInfo);
      break;
    case NOTIFICATION_DISMISSED_ACTION:
      notificationInfo = new NotificationInfo(NOTIFICATION_DISMISSED_ACTION,
          intentExtras.getInt(NOTIFICATION_NOTIFICATION_ID),
          intentExtras.getString(NOTIFICATION_TRACK_URL),
          intentExtras.getString(NOTIFICATION_TARGET_URL));
      manager.cancel(intent.getIntExtra(NOTIFICATION_NOTIFICATION_ID, -1));
      notificationPublishRelay.call(notificationInfo);
      break;
  }
}
 
Example 15
Source Project: DialogUtil   File: Tool.java    License: Apache License 2.0 5 votes vote down vote up
private  static void setHomeKeyListener(final Window window, final ConfigBean bean){
    //在创建View时注册Receiver
    IntentFilter homeFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    bean.homeKeyReceiver = new BroadcastReceiver() {
        final String SYSTEM_DIALOG_REASON_KEY = "reason";

        final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
                String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
                if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
                    // 处理自己的逻辑
                    if(bean.type == DefaultConfig.TYPE_IOS_INPUT){
                        hideKeyBoard(window);
                    }
                    if(!(bean.context instanceof Activity)){
                       Tool.dismiss(bean);
                    }

                    context.unregisterReceiver(this);
                }
            }
        }
    };
    bean.context.registerReceiver(bean.homeKeyReceiver, homeFilter);
}
 
Example 16
CloseDialogReceiver(Context context) {
    mContext = context;
    IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    context.registerReceiver(this, filter);
}
 
Example 17
private void hideStatusBar(final Context context) {
    final Intent closeStatusBarIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    context.sendBroadcast(closeStatusBarIntent);
}
 
Example 18
Source Project: YCVideoPlayer   File: HomeKeyWatcher.java    License: Apache License 2.0 4 votes vote down vote up
public HomeKeyWatcher(Context context) {
    mContext = context;
    mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
 
Example 19
public HomeWatcher(Context context) {
    mContext = context;
    mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
 
Example 20
Source Project: TurboLauncher   File: Launcher.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

	super.onCreate(savedInstanceState);

	initializeDynamicGrid();

	// the LauncherApplication should call this, but in case of
	// Instrumentation it might not be present yet
	mSharedPrefs = getSharedPreferences(
			LauncherAppState.getSharedPreferencesKey(),
			Context.MODE_PRIVATE);

	mDragController = new DragController(this);
	
	mInflater = getLayoutInflater();

	mStats = new Stats(this);

	mAppWidgetManager = AppWidgetManager.getInstance(this);

	mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
	mAppWidgetHost.startListening();

	mPaused = false;

	checkForLocaleChange();
	setContentView(R.layout.launcher);

	setupViews();
	mGrid.layout(this);

	registerContentObservers();

	lockAllApps();

	mSavedState = savedInstanceState;
	restoreState(mSavedState);

	if (!mRestoring) {
		if (DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE
				|| sPausedFromUserAction) {
			// If the user leaves launcher, then we should just load items
			// asynchronously when
			// they return.
			mModel.startLoader(true, PagedView.INVALID_RESTORE_PAGE);
		} else {
			// We only load the page synchronously if the user rotates (or
			// triggers a
			// configuration change) while launcher is in the foreground
			mModel.startLoader(true, mWorkspace.getRestorePage());
		}
	}

	// For handling default keys
	mDefaultKeySsb = new SpannableStringBuilder();
	Selection.setSelection(mDefaultKeySsb, 0);

	IntentFilter filter = new IntentFilter(
			Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
	registerReceiver(mCloseSystemDialogsReceiver, filter);

	updateGlobalIcons();

	// On large interfaces, we want the screen to auto-rotate based on the
	// current orientation
	unlockScreenOrientation(true);

	IntentFilter protectedAppsFilter = new IntentFilter(
			"phonemetra.intent.action.PROTECTED_COMPONENT_UPDATE");
	registerReceiver(protectedAppsChangedReceiver, protectedAppsFilter,
			"phonemetra.permission.PROTECTED_APP", null);
}