반응형
private fun resizeBitMap(uri: Uri, resize: Int): Bitmap? {
    var resizeBitmap: Bitmap? = null
    val ratioTemp = 2

    val options = BitmapFactory.Options()
    try {
        BitmapFactory.decodeStream(
            applicationContext.contentResolver.openInputStream(uri),
            null,
            options
        )
        var width = options.outWidth
        var height = options.outHeight
        var sampleSize = 1

        while (true) {
            if (width / ratioTemp < resize || height / ratioTemp < resize) break

            width /= ratioTemp
            height /= ratioTemp
            sampleSize *= ratioTemp
        }

        options.inSampleSize = sampleSize
        val bitmap = BitmapFactory.decodeStream(
            applicationContext.contentResolver.openInputStream(uri),
            null,
            options
        )
        resizeBitmap = bitmap

    } catch (e: FileNotFoundException) {
        e.printStackTrace()
    }

    return resizeBitmap
}
반응형
반응형

@Header 어노테이션 

 

1. 헤더 어노테이션을 추가하여 전송.

 

interface api {

@GET("/api/itemlist")

  fun itemList(

  @Header("token") token: String?,

  @Query("wid") wid : Int ): Call<List<ItemListResponseData>>

}

 

 

 

2. Interceptor를 이용하여 전송 

https://blog.codavel.com/how-to-create-an-http-interceptor-for-an-android-app-using-okhttp3

class AppInterceptor : Interceptor {

@Throws(IOException::class)

override fun intercept(chain: Interceptor.Chain) : Response = with(chain) {

                 val newRequest = request().newBuilder()

                .addHeader("(Key)", "(Value)")

                .build()

 

                proceed(newRequest)

   }

}

 

 

반응형
반응형

<style name="AlertDialogTheme" parent="android:Theme.Dialog">

    <item name="android:textSize">14sp</item>

</style>

 

 

ContextThemeWrapper cw = new ContextThemeWrapper( this, R.style.AlertDialogTheme );

AlertDialog.Builder b = new AlertDialog.Builder(cw);



출처: https://ondestroy.tistory.com/entry/AlertDialogBuilder-안에-텍스트-사이즈-조절하기 [OnCreate]

반응형
반응형

사진 저장 후 바로 보여지지가 않음.. 

해당 브로드캐스트를 호출 함으로써 갤러리에 업데이트를 할 수 있다. 

 

 

 

https://shinyongchul.tistory.com/91

 

ACTION_MEDIA_SCANNER_SCAN_FILE -> deprecated

이미지 저장 후 캘린더에 추가 하는 작업인데 아래 코드는 API 29 부터 사용할 수 없음. Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE).also { mediaScanIntent -> mediaScanIntent.data = Uri.fromFile(file) sendBroadcast(mediaScanInten

shinyongchul.tistory.com

 

반응형
반응형

1.우측 상단 Gradle 클릭

 

 

이미지에 보이는 선택된 파일을 더블클릭하면 됨.

반응형

'IT 이야기 > 2021_Android 이것저것' 카테고리의 다른 글

WebView SSL Issue  (0) 2022.03.18
안드로이드 Webview HTTP  (0) 2022.03.18
MotionLayout 맛보기..  (0) 2021.12.29
Android Doze Mode 와 배터리 사용량 최적화 제외  (0) 2021.12.13
GPS 위치 정확도 승인  (0) 2021.12.07
반응형

onReceivedSslError 보안 알림 해제 방법 

 

m_webView.setWebViewClient(new WebViewClient() {

   @Override
   public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error)
   {
      //super.onReceivedSslError(view, handler, error);
      final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.sharedActivity().getContext());
      builder.setMessage("이 사이트의 보안 인증서는 신뢰할 수 없습니다.");
      builder.setPositiveButton("continue", new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
            handler.proceed();
         }
      });
      builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
            handler.cancel();
         }
      });
      final AlertDialog dialog = builder.create();
      dialog.show();

   });
반응형
반응형

통신이 HTTPS프로토콜을 이용하여 접속할경우

리소스들( 이미지 )을 HTTP프로토콜로 불러올때 구글 자체에서 보안상 문제가 있다고 판단하여

안드로이드 LOLLIPOP ( 5.x )이상부터는 아래와 같이 로그가 나온다.

"This request has been blocked; the content must be served over"

 

이럴때는 아래와같은 코드로 적용.

WebSettings wsetting = m_webView.getSettings();

if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.LOLLIPOP ) {
	wsetting.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}

 

 

 

 

반응형
반응형

하드코딩 하지말라는 경고인데 타이틀 어노테이션을 적어주면 무시함.

 

 

반응형
반응형

If you are using Apple M1 chip

One of the release notes they have mentioned by jetpack (Version 2.4.0-alpha03 )

  • Fixed an issue with Room’s SQLite native library to support Apple’s M1 chips.

Change Version to 2.4.0-alpha03 or above

implementation "androidx.room:room-runtime:2.4.0-alpha03"
annotationProcessor "androidx.room:room-compiler:2.4.0-alpha03"
kapt 'androidx.room:room-compiler:2.4.0-alpha03'

Reference

https://developer.android.com/jetpack/androidx/releases/room#version_240_2

 

Room  |  Android 개발자  |  Android Developers

Room Room 지속성 라이브러리는 SQLite에 추상화 레이어를 제공하여 SQLite를 완벽히 활용하면서 더 견고한 데이터베이스 액세스를 가능하게 합니다. 최근 업데이트 안정적인 버전 출시 후보 베타 버

developer.android.com

 

 

Mac M1 은 2.4 이상을 설치 해야함. ?

반응형
반응형

gradle 업데이트 이후 ... 

그냥 단순하게 hilt 사용할려고하는데

안된다..오류도 불친절하다...

android developer 사이트에서 하라는데로 했는데 .. 

 

아래 설명대로 하니깐 일단됨... 

https://dagger.dev/hilt/gradle-setup.html

 

Gradle Build Setup

Hilt dependencies To use Hilt, add the following build dependencies to the Android Gradle module’s build.gradle file: dependencies { implementation 'com.google.dagger:hilt-android:2.40.5' annotationProcessor 'com.google.dagger:hilt-compiler:2.40.5' // Fo

dagger.dev

 

gradle 과의 관계라고 해야하나..이부분 이해도가 부족해서 발생한 문제다... 

정말 속 시원하게 알고싶다 ㅠㅠ..

반응형

+ Recent posts