package com.xxxx; import android.content.Context; import android.content.SharedPreferences; import butterknife.ButterKnife; public class BindBluetoothDevice extends AppCompatActivity { //打开Preferences,名称为setting,如果存在则打开它,否则创建新的Preferences public SharedPreferences pkeUserSettings = null; //让setting处于编辑状态 //SharedPreferences.Editor editor = userSettings.edit(); //editor.putString("name","ATAAW"); //editor.commit(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bind_bluetooth_device); bindBluetoothDevicethis = this; ButterKnife.bind(this); updateMenu(); pkeUserSettings = getSharedPreferences("PkeSetting", 0); } @Override public void onDestroy() { super.onDestroy(); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem more = menu.add(0, 1, 0, "输入"); more.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); if(mMenuVisible) { more.setVisible(true); } else { more.setVisible(false); } return super.onCreateOptionsMenu(menu); } //隐藏菜单 private void updateMenu(){ mMenuVisible = false; supportInvalidateOptionsMenu(); } @Override protected void onPause() { super.onPause(); mScanner.scanLeDevice(-1, false); } @Override public void onResume() { super.onResume(); } @OnClick({R.id.imageViewBcak, R.id.mtvCommit}) public void OnClick(View v){ switch (v.getId()){ default: break; } } }
Intent intent = new Intent(this, SecondActivity.class); startActivity(intent); //startActivity方法