System.out.println("true 체크테스트");
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("checked",true).apply();
final boolean isChecked = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("checked", false);
if(isChecked){
androidx.appcompat.app.AlertDialog.Builder alert = new androidx.appcompat.app.AlertDialog.Builder(MainActivity.this);
alert.setPositiveButton("확인", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.out.println("퍼미션 DIALOG_ID 체크테스트");
dialog.dismiss();
}
}).setNegativeButton("거부",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "필수권한이 거부되어 앱을 종료합니다", Toast.LENGTH_SHORT).show();
finish();
}
});
alert.setMessage("예이예이예");
alert.show();
}
처음 앱실행후 퍼미션체크처럼 한번만띄우고싶습니다.
얼럿창검색하면 버튼클릭시에 나오는것이나.. 체크박스부분같은경우는 리스트체크같은것만나와서 어떤식으로 검색해야할지 모르겟습니다.
메인창에 띄우기위해 protected void onCreate에 코드를 짜놧습니다.
해본것
1. 전역변수를 만들어서
if(cont == 0){
코드실행..
}
int cont = 0;
확인버튼 누를시
int a= 0;
a++;
cont = a;
system.out.printIn("값이올랏나?"+cont); 이런식으로 로그에 1이라고 제대로 찍힙니다.
그런데 앱종료후 다시 실행하면 초기값을 0으로줘서 그런지 초기화되잇더라구요 ㅜㅜ
2. 트루펄스
is(isChecked[0] == true){
소스실행..
}
확인버튼 누를시isChecked[0] = false;
3. 체크박스
이건 체크박스자체가 안먹네요 ㅜㅜ