You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.7 KiB
Java

8 months ago
package com.example.writeepc;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.RadioButton;
import android.widget.Toast;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.base.MyApplication;
import com.handheld.uhfr.UHFRManager;
public class HomeActivity extends BaseActivity {
private UHFRManager uhfrManager;
private long exitTime = 0L;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
uhfrManager = UHFRManager.getInstance();
MyApplication.getApplication().setUhfrManager(uhfrManager);
RadioButton button1 = this.findViewById(R.id.home_1);
RadioButton button2 = this.findViewById(R.id.home_2);
button1.setOnClickListener(v -> {
startActivity(new Intent(this, ShuangqianActivity.class));
});
button2.setOnClickListener(v -> {
startActivity(new Intent(this, ShuangqianActivity2.class));
});
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == 4) {
if ((System.currentTimeMillis() - exitTime) > 2000) {
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
return true;
} else {
finish();
}
}
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (uhfrManager != null) {
uhfrManager.close();
uhfrManager = null;
}
}
}