달력

2

« 2021/2 »

  • 28
  •  
  •  
  •  
  •  
  •  
  •  
반응형




 

shouldOverrideUrlLoading() 함수 대체

boolean shouldOverrideUrlLoading(WebView view, String url) DEPRECATED되어

boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) 동일하게 처리합니다.

 @Override

public boolean shouldOverrideUrlLoading(WebView view, String url) {

//            return super.shouldOverrideUrlLoading(view, url);

            Toast t=Toast.makeText(MainActivity.this, url, Toast.LENGTH_SHORT) ;

            t.show();

            return true;

 

}

 

@Override

public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {

//            return super.shouldOverrideUrlLoading(view, request);

            Toast t=Toast.makeText(MainActivity.this, request.getUrl().toString(), Toast.LENGTH_SHORT) ;

            t.show();

            return true;

 

}

 

 



에러메시지

boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) 동일하게 처리할 getURL() 사용하기 위해서는 SDK 21 필요한데 현재 버전 15여서 사용할 없기 때문에 에러가 발생합니다. , 최소 SDK 버전이 맞지 않아 에러가 발생합니다.

Call requires API level 21 (current min is 15): android.webkit.WebResourceRequest#getUrl less... (Ctrl+F1)

 


 

 

 


 


해결방법

build.gradle(Module) 그래들의 minSdkVersion 버전을 21 수정합니다. >>

우측 상단의 [Sync now] 링크를 클릭합니다.

android {

    compileSdkVersion 27

    defaultConfig {

        applicationId "com.tistory.codedragon.b45"

        minSdkVersion 15

        targetSdkVersion 27

        versionCode 1

        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }

    }

}

android {

    compileSdkVersion 27

    defaultConfig {

        applicationId "com.tistory.codedragon.b45"

        minSdkVersion 21

        targetSdkVersion 27

        versionCode 1

        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }

    }

}

 





반응형
Posted by codedragon codedragon

댓글을 달아 주세요