Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 코틀린 이미지저장 #파일저장
- 생분해성 플라스틱
- 안드로이드 비콘
- withContext
- livedata
- 코틀린 트리거 버튼
- 스레드 #코루틴
- Room 데이터베이스 업데이트
- 안드로이드 sms
- 셀룰로오스-g-폴리락타이드 공중합체
- compse state
- 1회용컵
- 일회용 플라스틱
- 라이브데이터 postValue
- bluetoothmanager
- 안드로이드 mvvm
- #큐구조 #큐다운로드
- compse collectAsState
- 1회용 플라스틱컵
- apk이름변경
- 안드로이드스튜디오 jdk
- var 와 val
- 코루틴 job
- TowmonUSB 연결오류
- 안드로이드 스튜디오 애뮬레이터
- viewmodelscope
- json 저장
- TwomonUSB
- 토글 험수
- 플라스틱 생분해
Archives
- Today
- Total
EnjoyLife
루팅단말기일 경우 실행 차단 본문
코틀린 버전
private fun isRooted(): Boolean {
val buildTags = android.os.Build.TAGS
if (buildTags != null && buildTags.contains("test-keys")) {
return true
}
try {
val file = File("/system/app/Superuser.apk")
if (file.exists()) {
return true
}
} catch (e: Exception) {
}
val rootBinaryPaths = arrayOf(
"/sbin/su", "/system/bin/su", "/system/xbin/su", "/system/sd/xbin/su",
"/system/bin/failsafe/su", "/data/local/su", "/su/bin/su"
)
for (path in rootBinaryPaths) {
try {
val file = File(path)
if (file.exists()) {
return true
}
} catch (e: Exception) {
}
}
return false
}
자바 버전
public boolean isRooted() {
Process process = null;
try {
process = Runtime.getRuntime().exec("su -c ls /data");
return process.waitFor() == 0;
} catch (Exception e) {
return false;
} finally {
if (process != null) {
process.destroy();
}
}
}
if(isRooted()){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
alertDialogBuilder
.setMessage("루트권한을 가진 디바이스에서는 실행할 수 없습니다.")
.setCancelable(false)
.setPositiveButton("확인",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog, int id) {
moveTaskToBack(true);
finish();
android.os.Process.killProcess(android.os.Process.myPid());
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
return;
}
'안드로이드 개발 > 개발팁' 카테고리의 다른 글
함수의 마지막 인자로 람다를 쓰는 이유 (0) | 2023.11.01 |
---|---|
안드로이드스튜디오 애뮬레이터 죽어도 실행안될때 (2) | 2023.10.30 |
MediaBrowserService 와 MediaSessionCompat 을 이용해서 exoplayer 만들기 (0) | 2023.10.26 |
remember 와 rememberSaveable 의 차이 (0) | 2023.10.25 |
companion object 싱글턴과 커스텀 싱글턴의 차이 (0) | 2023.10.24 |