날짜 형식 처리 안정성 강화 및 트랜잭션 삭제 시 앱 먹통 문제 해결
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.lovable.zellyfinance;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import com.getcapacitor.JSObject;
|
||||
import com.getcapacitor.Plugin;
|
||||
import com.getcapacitor.PluginMethod;
|
||||
import com.getcapacitor.annotation.CapacitorPlugin;
|
||||
import com.getcapacitor.PluginCall;
|
||||
|
||||
/**
|
||||
* 애플리케이션 빌드 정보를 제공하는 Capacitor 플러그인
|
||||
*/
|
||||
@CapacitorPlugin(name = "BuildInfo")
|
||||
public class BuildInfoPlugin extends Plugin {
|
||||
private static final String TAG = "BuildInfoPlugin";
|
||||
|
||||
/**
|
||||
* 빌드 정보를 가져오는 메서드
|
||||
* @param call 플러그인 호출 정보
|
||||
*/
|
||||
@PluginMethod
|
||||
public void getBuildInfo(PluginCall call) {
|
||||
try {
|
||||
Log.d(TAG, "빌드 정보 요청 수신됨");
|
||||
|
||||
JSObject ret = new JSObject();
|
||||
|
||||
// 빌드 정보 수집
|
||||
String versionName = BuildConfig.VERSION_NAME;
|
||||
int versionCode = BuildConfig.VERSION_CODE;
|
||||
int buildNumber = BuildConfig.BUILD_NUMBER;
|
||||
String packageName = getContext().getPackageName();
|
||||
|
||||
// 디버깅을 위한 로그 출력
|
||||
Log.d(TAG, "버전명: " + versionName);
|
||||
Log.d(TAG, "버전 코드: " + versionCode);
|
||||
Log.d(TAG, "빌드 번호: " + buildNumber);
|
||||
Log.d(TAG, "패키지명: " + packageName);
|
||||
|
||||
// 결과 객체에 값 설정
|
||||
ret.put("versionName", versionName);
|
||||
ret.put("versionCode", versionCode);
|
||||
ret.put("buildNumber", buildNumber);
|
||||
ret.put("packageName", packageName);
|
||||
ret.put("androidVersion", Build.VERSION.RELEASE);
|
||||
ret.put("androidSDK", Build.VERSION.SDK_INT);
|
||||
|
||||
// 현재 날짜를 디버깅 정보로 추가
|
||||
ret.put("buildDate", new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date()));
|
||||
|
||||
Log.d(TAG, "빌드 정보 요청 성공 처리");
|
||||
call.resolve(ret);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "빌드 정보 가져오기 실패", e);
|
||||
JSObject errorResult = new JSObject();
|
||||
errorResult.put("versionName", "1.0.0");
|
||||
errorResult.put("versionCode", 1);
|
||||
errorResult.put("buildNumber", 1);
|
||||
errorResult.put("error", e.getMessage());
|
||||
call.resolve(errorResult); // 에러가 발생해도 앱이 중단되지 않도록 resolve 호출
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user