在检查导航栏时崩溃了

时间:2015-01-08 04:16:32

标签: android navigation

public class MainActivity extends Activity{

  TextView tv;

private Context context;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    tv= (TextView)findViewById(R.id.mainTextView);

    boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
    boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);

    if (!hasMenuKey && !hasBackKey && !hasHomeKey) {
        tv.setText("Has Present");
    } else {
        tv.setText("Has Not!");
    }
   }
   }

我正在尝试检查设备是否在某些设备上有导航栏,导航栏+硬键“一加一”,而其他设备在自定义ROM上运行,因此我尝试检查导航栏是否可用< / p>

但它在检查我应该做什么时崩溃了

0 个答案:

没有答案