天天看点

监听Home键

private

void

receive(Context context, Intent intent){

String action = intent.getAction();

if

(action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {

String systemReason= intent.getStringExtra(

"reason"

);

if

(systemReason !=

null

) {

if

( systemReason.equals(

"homekey"

) ){

// 按Home按键

                        // 要做的操作

}

else

if

( systemReason.equals(

"recentapps"

) ){

// 长按Home按键

// 要做的操作

}

}

}

}

继续阅读