Android
uiOverrideUrlLoading
aucd29
2013. 10. 8. 14:52
어디서 Browser intent를 호출하나 봤더니 이놈 수정해서 쓰면 될 듯
일단 mWebViewClient 이 instance 안되어 있으면 새로 띄우는 구조, mWebViewClient 를 만들어주면 mWebViewClient 으로 Event 를 보낼 테니 소스 수정을 하지 않기를 원한다면 이를 만들어 주는게 가장 현명한 선택인 듯
CallbackProxy.java
[code]
public boolean uiOverrideUrlLoading(String overrideUrl) {
if (overrideUrl == null || overrideUrl.length() == 0) {
return false;
}
boolean override = false;
if (mWebViewClient != null) {
override = mWebViewClient.shouldOverrideUrlLoading(mWebView,
overrideUrl);
} else {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(overrideUrl));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
// If another application is running a WebView and launches the
// Browser through this Intent, we want to reuse the same window if
// possible.
intent.putExtra(Browser.EXTRA_APPLICATION_ID,
mContext.getPackageName());
try {
mContext.startActivity(intent);
override = true;
} catch (ActivityNotFoundException ex) {
// If no application can handle the URL, assume that the
// browser can handle it.
}
}
return override;
}
[/code]
일단 mWebViewClient 이 instance 안되어 있으면 새로 띄우는 구조, mWebViewClient 를 만들어주면 mWebViewClient 으로 Event 를 보낼 테니 소스 수정을 하지 않기를 원한다면 이를 만들어 주는게 가장 현명한 선택인 듯
CallbackProxy.java
[code]
public boolean uiOverrideUrlLoading(String overrideUrl) {
if (overrideUrl == null || overrideUrl.length() == 0) {
return false;
}
boolean override = false;
if (mWebViewClient != null) {
override = mWebViewClient.shouldOverrideUrlLoading(mWebView,
overrideUrl);
} else {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(overrideUrl));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
// If another application is running a WebView and launches the
// Browser through this Intent, we want to reuse the same window if
// possible.
intent.putExtra(Browser.EXTRA_APPLICATION_ID,
mContext.getPackageName());
try {
mContext.startActivity(intent);
override = true;
} catch (ActivityNotFoundException ex) {
// If no application can handle the URL, assume that the
// browser can handle it.
}
}
return override;
}
[/code]