我正在为 firestick 制作应用程序,但没有点击或导航抽屉无法使用 Firestick Remote。
public class MainActivity extends AppCompatActivity {
int currentApiVersion;
SharedPreferences sharedpreferences;
String code = "";
public static DrawerLayout drawer_layout;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
currentApiVersion = Build.VERSION.SDK_INT;
HideHomeButton.hidebar2(this);
setContentView(R.layout.activity_new_main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this,android.R.color.black));
}
TextView menu_code = findViewById(R.id.menu_code);
drawer_layout = findViewById(R.id.drawer_layout);
sharedpreferences = this.getSharedPreferences("code_prefrances", Context.MODE_PRIVATE);
code = sharedpreferences.getString("code", "");
menu_code.setText(code);
HomeFragment fragment = new HomeFragment();
FragmentManager manager = getSupportFragmentManager();;
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.container, fragment).addToBackStack(null);
transaction.commit();
findViewById(R.id.reset_code).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),CodeInputActvity.class);
startActivity(intent);
if (drawer_layout.isDrawerOpen(GravityCompat.END)) {
drawer_layout.closeDrawer(GravityCompat.END);
}
}
});
findViewById(R.id.refresh).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
if (drawer_layout.isDrawerOpen(GravityCompat.END)) {
drawer_layout.closeDrawer(GravityCompat.END);
}
}
});
findViewById(R.id.reboot_app).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SharedPreferences sharedpreferences = getSharedPreferences("code_prefrances", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.remove("code");
editor.commit();
Intent intent = new Intent(getApplicationContext(),SplashActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
if (drawer_layout.isDrawerOpen(GravityCompat.END)) {
drawer_layout.closeDrawer(GravityCompat.END);
}
}
});
}