android.content.Intent#ACTION_CLOSE_SYSTEM_DIALOGS源码实例Demo

下面列出了android.content.Intent#ACTION_CLOSE_SYSTEM_DIALOGS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Noyze   文件: AudioHelper.java
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);
}
 
源代码2 项目: buyingtime-android   文件: AlarmReceiver.java
@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);

}
 
源代码3 项目: NotifyMe   文件: ActionReceiver.java
@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));
    }
}
 
/** 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;
}
 
@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);
}
 
源代码6 项目: Saiy-PS   文件: SaiyTileService.java
@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);
    }
 
源代码7 项目: MobileGuard   文件: LockedActivity.java
/**
 * 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);
}
 
@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");
    }
}
 
源代码9 项目: android_9.0.0_r45   文件: DreamController.java
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");
}
 
源代码10 项目: android-kiosk-mode   文件: MainActivity.java
@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);
    }
}
 
源代码11 项目: imsdk-android   文件: IMBaseActivity.java
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);
}
 
@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");
    }
}
 
源代码13 项目: SystemUITuner2   文件: BatteryTileService.java
@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);
}
 
源代码14 项目: aptoide-client-v8   文件: NotificationReceiver.java
@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;
  }
}
 
源代码15 项目: DialogUtil   文件: Tool.java
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);
}
 
源代码16 项目: android_9.0.0_r45   文件: ShutdownThread.java
CloseDialogReceiver(Context context) {
    mContext = context;
    IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    context.registerReceiver(this, filter);
}
 
private void hideStatusBar(final Context context) {
    final Intent closeStatusBarIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    context.sendBroadcast(closeStatusBarIntent);
}
 
源代码18 项目: YCVideoPlayer   文件: HomeKeyWatcher.java
public HomeKeyWatcher(Context context) {
    mContext = context;
    mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
 
源代码19 项目: always-on-amoled   文件: HomeWatcher.java
public HomeWatcher(Context context) {
    mContext = context;
    mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
 
源代码20 项目: TurboLauncher   文件: Launcher.java
@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);
}
 
 方法所在类
 同类方法