Android - 菜单按钮可打开系统活动应用

时间:2016-06-01 08:03:09

标签: android

我有三星平板电脑SM-T560,按下触摸菜单'键(在硬件'主页'按钮旁边)打开“活动应用”按钮的系统菜单您可以在此处关闭或导航到之前打开的应用程序。

如何覆盖此功能?我想在此菜单按钮单击时禁用显示活动应用程序。

1 个答案:

答案 0 :(得分:1)

您需要使用活动中的@Override public boolean onKeyDown(int keycode, KeyEvent event) { switch(keycode) { case KeyEvent.KEYCODE_MENU: //Your functionality here return true; } return super.onKeyDown(keycode, event); } 方法覆盖菜单按钮。以下代码段应该是一个很好的开始:

private static final String STR1 = "Str_1";
private static final String STR2 = "Str_2";
private static final char NEW_LINE = (char)0x0A;
//private static final String NEW_LINE = "\n";

public static void main(String[] args) {

    //They all return CR+LF instead of LF only.
    System.out.println("Str_1\nStr_2");

    System.out.print(STR1+NEW_LINE+STR2);

    try{
        FileOutputStream fos = new FileOutputStream("tests\\newline_test.txt");
        fos.write((STR1+NEW_LINE+STR2).getBytes()); //The case I'm mostly interested into
        fos.close();
    } catch (IOException e){
        e.printStackTrace();
    }
}