반응형
package app.m;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class start extends Activity {
WebView mWeb;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
mWeb = (WebView)findViewById(R.id.webview);
mWeb.setWebViewClient(new MyWebClient());
WebSettings set = mWeb.getSettings();
set.setJavaScriptEnabled(true);
set.setBuiltInZoomControls(true);
mWeb.loadUrl("http://주소");
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWeb.canGoBack()){
mWeb.goBack();
} else if ((keyCode == KeyEvent.KEYCODE_BACK)) {
finish();
}
return true;
}
class MyWebClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.matches(".*mp4.*")){
Intent call_phone = new Intent(Intent.ACTION_VIEW , Uri.parse(url)) ;
startActivity(call_phone);
return true;
} else if(url.startsWith("http://")||url.startsWith("https://")){
view.loadUrl(url);
return true;
} else {
return false;
}
}
}
}
반응형
'개발 > Android' 카테고리의 다른 글
[Android] E/ViewRootImpl: sendUserActionEvent() mView == null (0) | 2016.05.01 |
---|---|
[Android] textScaleX (0) | 2016.04.27 |
[Android] Fragment 에서 getActivity() (0) | 2016.04.27 |
[Android] apache.http.client (0) | 2016.04.13 |
[Android] getCacheDir, getFilesDir, getExternalCacheDir (0) | 2016.04.10 |
[Android] assetmanager 와 sqliteopenhelper 에 대한 이야기. (0) | 2016.04.10 |
[Android] Material 디자인 관련 주소 (0) | 2016.04.09 |
[Android] Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE (0) | 2014.09.23 |