天天看點

監聽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按鍵

// 要做的操作

}

}

}

}

繼續閱讀