樓主您好,非常感謝您的辛苦勞動
以下代碼可實現(xiàn) :按遙控器主頁鍵,立即直接返回當(dāng)貝桌面,沒有延遲!
官方的是按遙控器主頁鍵打開一個對話框,選擇桌面,延遲5秒再打開
public void onHomePressed() {
String myPkgName = getPackageName();
SharedPreferences sp = getSharedPreferences("general_file", 0);
if (res == null) {
if (getHomes() != null && !getHomes().equals(myPkgName) && sp.getBoolean("home_buzaitixing", true)) {
Intent intent = new Intent(this, (Class<?>) IndexActivity.class);
intent.addFlags(268435456);
PendingIntent.getActivity(this, 0, intent, 0).send();
return;
}
return;
}
if (!res.activityInfo.packageName.equals(myPkgName) && sp.getBoolean("home_buzaitixing", true)) {
Intent intent2 = new Intent(this, (Class<?>) IndexActivity.class);
intent2.addFlags(268435456);
PendingIntent.getActivity(this, 0, intent2, 0).send();
}
} |