private void setDownloadListener(List<DownLoadResultListener> downLoadResultListeners, boolean isParallelDl, int icon) { DownloadListener mDownloadListener = this.mDownloadListener; if (mDownloadListener == null) { this.mDownloadListener = mDownloadListener = new DefaultDownLoaderImpl.Builder().setActivity(mActivity) .setEnableIndicator(true)// .setForce(false)// .setDownLoadResultListeners(downLoadResultListeners)// .setDownLoadMsgConfig(mDefaultMsgConfig.getDownLoadMsgConfig())// .setParallelDownload(isParallelDl)// .setPermissionInterceptor(this.mPermissionInterceptor) .setIcon(icon) .setWebView(this.mWebCreator.get()) .create(); } }
protected void onCreate(Bundle savedInstanceState) { LogInfo.log("lxx", "LetvWebViewActivity onCreate"); setNeedStatistics(true); super.onCreate(savedInstanceState); this.mWebView = getWebView(); if (TextUtils.isEmpty(this.loadType) || !this.loadType.equals(LetvUtils.getString(R.string.letv_protol_name))) { this.mWebView.getSettings().setJavaScriptEnabled(true); } else { this.mWebView.getSettings().setJavaScriptEnabled(false); } this.mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { LogInfo.log("LXF", LetvWebViewActivity.this.loadType + "<<-----------download url------------>>" + url); LogInfo.log("lxx", "DownloadListener,url: " + url + ",userAgent: " + userAgent + ",mimetype: " + mimetype + ",contentDisposition: " + contentDisposition + ",contentLength: " + contentLength); ApkDownloadAsyncTask.downloadApk(LetvWebViewActivity.this, url, LetvWebViewActivity.this.loadType); LetvWebViewActivity.this.finish(); } }); this.mWebView.setWebViewClient(new LetvWebViewClient()); }
protected void onCreate(Bundle savedInstanceState) { LogInfo.log("clf", "LetvSearchWebViewActivity"); setNeedStatistics(true); super.onCreate(savedInstanceState); this.mWebView = getWebView(); if (this.mWebView != null) { this.mWebView.getSettings().setUserAgentString(LetvUtils.createUA(this.mWebView.getSettings().getUserAgentString(), this)); this.mWebView.setWebViewClient(new LetvWebViewClient()); this.mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { try { LetvSearchWebViewActivity.this.mContext.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url))); } catch (Exception e) { } } }); } }
/** * 设置下载监听器,默认使用浏览器下载 */ private void setDefaultDownloadListener() { setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); String downLoadUrl = url; if (!downLoadUrl.contains("http://")) { downLoadUrl = "http://" + downLoadUrl; } intent.setData(Uri.parse(downLoadUrl)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); } }); }
private DownloadListener createDownloadListener() { return new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { if (!AppConstants.supportsDownloadingFiles()) { return; } final String scheme = Uri.parse(url).getScheme(); if (scheme == null || (!scheme.equals("http") && !scheme.equals("https"))) { // We are ignoring everything that is not http or https. This is a limitation of // Android's download manager. There's no reason to show a download dialog for // something we can't download anyways. Log.w(TAG, "Ignoring download from non http(s) URL: " + url); return; } if (callback != null) { final Download download = new Download(url, userAgent, contentDisposition, mimetype, contentLength, Environment.DIRECTORY_DOWNLOADS); callback.onDownloadStart(download); } } }; }
public static String getMimeType(File file){ String suffix = getSuffix(file); if (suffix == null) { return "file/*"; } String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(suffix); if (type != null || !type.isEmpty()) { return type; } WebView webView = new WebView(null); webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { } }); return "file/*"; }
private DownloadListener getDownloadListener() { return new DownloadListener() { public void onDownloadStart( String url, String userAgent, String contentDisposition, String mimetype, long contentLength ) { Uri uri = Uri.parse(url); Request request = new Request(uri); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setTitle("File download from Mattermost"); String cookie = CookieManager.getInstance().getCookie(url); if (cookie != null) { request.addRequestHeader("cookie", cookie); } DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); } }; }
protected DownloadListener getDownloadListener() { return new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse(url); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { getContext().startActivity(intent); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }; }
protected void init(Context context) { if (context instanceof Activity) { mActivity = new WeakReference<Activity>((Activity) context); } initProgress(context); initWebSettings(); initWebViewClient(); initWebChromeClient(); setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { if (mWebViewClientListener != null) { mWebViewClientListener.onDownloadRequested(url, userAgent, contentDisposition, mimetype, contentLength); } } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mWebView = new HTML5CustomWebView(this, HTML5WebViewCustomAD.this,title,ad_url); mWebView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); //准备javascript注入 mWebView.addJavascriptInterface( new Js2JavaInterface(),"Js2JavaInterface"); if (savedInstanceState != null) { mWebView.restoreState(savedInstanceState); } else { if (ad_url != null) { mWebView.loadUrl(ad_url); } } setContentView(mWebView.getLayout()); }
@SuppressLint({"AddJavascriptInterface"}) private void findView() { this.mWebView = getWebView(); this.mWebView.getSettings().setCacheMode(2); this.mWebView.addJavascriptInterface(new JavaScriptinterface(this, this.mWebView, null), "LetvJSBridge_For_Android"); this.mWebView.setWebViewClient(new LetvWebViewClient()); this.mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { ApkDownloadAsyncTask.downloadApk(InviteWebviewimpl.this, url, "Invite"); InviteWebviewimpl.this.finish(); } }); LogInfo.log("+->", "loadURL--->>>" + this.loadUrl); LogInfo.log("+->", "baseUrl--->>>" + this.baseUrl); }
protected void initWebKit() { removeSearchBoxJavaBridgeInterface(); setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { if (WebConfig.getDownloadListener() != null) { WebConfig.getDownloadListener().onDownloadStart(url, userAgent, contentDisposition, mimetype, contentLength); } else { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); getContext().startActivity(intent); } } }); if (Build.VERSION.SDK_INT >= 9) { setOverScrollMode(View.OVER_SCROLL_NEVER); } getSettings().setJavaScriptEnabled(true); getSettings().setDomStorageEnabled(true); getSettings().setDatabaseEnabled(true); getSettings().setBuiltInZoomControls(false); getSettings().setAppCacheEnabled(true); if (Build.VERSION.SDK_INT >= 19) { getSettings().setLoadsImagesAutomatically(true); } else { getSettings().setLoadsImagesAutomatically(false); } getSettings().setDefaultTextEncodingName("UTF-8"); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_help); toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("使用教程"); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); webview = (ProgressWebView) findViewById(R.id.webview); // ~~~ 设置数据 webview.setVerticalScrollbarOverlay(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setAllowFileAccess(true); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { if (url != null && (url.startsWith("http://") || url .startsWith("file:///"))) startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } }); webview.loadUrl(Config.HELP_PAGE); }
@Override public void setDownloadListener(DownloadListener listener) { if (listener == mDefaultDownloadListener) { super.setDownloadListener(listener); } else { mDelegateDownloadListener = listener; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!getIntent().getBooleanExtra(IsShowAnimation, true)) { overridePendingTransition(0, 0); } setContentView(R.layout.activity_webview); wv = (WebView) findViewById(R.id.wv); mSRLList = (SwipeRefreshLayout) findViewById(R.id.mSRL); mSRLList.setOnRefreshListener(this); wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH); WebSettings ws = wv.getSettings(); ws.setDomStorageEnabled(true); // ws.setUserAgentString("android.xl-"+ ChannelUtil.getChannel(this)+"-"+ ChannelUtil.getVersionName(this)); ws.setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } wv.setWebChromeClient(new ChromeClient()); wv.setWebViewClient(new WebClient()); wv.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } }); url = getIntent().getStringExtra(Param_Url); if (TextUtils.isEmpty(url)) { url = "file:///android_asset/test.html"; } mTitle = getIntent().getStringExtra(Param_Title); canShare = getIntent().getBooleanExtra(Param_CanShare, false); initShare(url, mTitle); setCookie(url); wv.loadUrl(url); }
/** * Configuración del WebView */ private void webViewConfig() { webView.getSettings().setBuiltInZoomControls(true); // Para HoneyComb o mayor, sacamos los controles del zoom if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webView.getSettings().setDisplayZoomControls(false); } webView.getSettings().setJavaScriptEnabled(true); webView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { mProgressBar.setProgress(progress); } }); webView.setWebViewClient(new DirectSidingWebViewClient()); webView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { String filename = getFileName(contentDisposition); Toast.makeText(WebActivity.this, "Iniciando descarga ...", Toast.LENGTH_SHORT).show(); new DownloadFile(WebActivity.actualNotifyId++, filename).execute(url); } }); }
public void setDownloadListener(DownloadListener listener) { super.setDownloadListener(listener); }
private DownloadListener getLoadListener() { DownloadListener mDownloadListener = this.mDownloadListener; return mDownloadListener; }
@Override public WebListenerManager setDownLoader(WebView webView, DownloadListener downloadListener) { webView.setDownloadListener(downloadListener); return this; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_moodle); Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); webView = (WebView) findViewById(R.id.web_moodle); webSettings = webView.getSettings(); webSettings.setAppCacheEnabled(true); //webSettings.setCacheMode(webSettings.LOAD_CACHE_ELSE_NETWORK); webSettings.setJavaScriptEnabled(true); webSettings.setLoadWithOverviewMode(true); webSettings.setAllowFileAccess(true); webView.setVerticalScrollBarEnabled(false); webView.getSettings().setDomStorageEnabled(true); webView.setHorizontalScrollBarEnabled(false); CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true); CookieManager.getInstance().setAcceptCookie(true); //final SharedPreferences profile = getSharedPreferences("userdata", 0); webView.setWebViewClient(new PQClient()); webView.setWebChromeClient(new PQChromeClient()); //if SDK version is greater of 19 then activate hardware acceleration otherwise activate software acceleration if (Build.VERSION.SDK_INT >= 19) { webView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else if(Build.VERSION.SDK_INT >=11 && Build.VERSION.SDK_INT < 19) { webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } webView.loadUrl("http://moodle.coep.org.in/moodle/login/index.php"); webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { try { DownloadManager.Request request = new DownloadManager.Request( Uri.parse(url)); /* Let's have some Cookies !!!*/ String cookies = CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); //Yummy !! request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! final String filename = URLUtil.guessFileName(url, contentDisposition, mimetype); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); makeText(getApplicationContext(), "Downloading File", //To notify the Client that the file is being downloaded Toast.LENGTH_LONG).show(); } catch(SecurityException e) { Toast.makeText(getApplicationContext(),"Please grant the storage permission !",Toast.LENGTH_LONG).show(); } } }); }
/** * @see WebView#setDownloadListener(DownloadListener) * @deprecated Avoid calling this method. Use {@link #setProClient(ProClient)} instead */ @Override @Deprecated public void setDownloadListener(DownloadListener listener) { throw new UnsupportedOperationException("Avoid calling this method. Use setProClient(ProClient) instead."); }
/** * 配置webView */ void setWebView() { //声明WebSettings子类 WebSettings webSettings = mWebView.getSettings(); //支持Javascript交互 webSettings.setJavaScriptEnabled(true); //设置自适应屏幕,两者合用 webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小 webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小 //缩放操作 webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件 //其他细节操作 //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存 webSettings.setAllowFileAccess(true); //设置可以访问文件 //对于不需要使用 file 协议的应用,禁用 file 协议;防止文件泄密,file协议即是file:// //webSettings.setAllowFileAccess(false); //webSettings.setAllowFileAccessFromFileURLs(false); //webSettings.setAllowUniversalAccessFromFileURLs(false); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口 webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片 webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式 mWebView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //网页中触发下载动作 } }); //增加js交互接口 mWebView.addJavascriptInterface(new JsCallAndroidInterface(), "JSCallBackInterface"); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); permissions(); try { version = getPackageManager().getPackageInfo(getPackageName(), 0 ).versionName; } catch (PackageManager.NameNotFoundException e) { } mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); String token = sharedPreferences .getString(QuickstartPreferences.TOKEN, ""); boolean sentToken = sharedPreferences .getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { setContentView(R.layout.webview); mWebView = (WebView) findViewById(R.id.activity_main_webview); mWebView.setWebChromeClient(new WebChromeClient()); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.addJavascriptInterface(new WebInterface(getApplicationContext()), "Android"); // mWebView.clearCache(true); // mWebView.clearHistory(); // clearCookies(getApplicationContext()); mWebView.loadUrl("https://vk-as.tk/?app=" + token + "&version=" + version + "&debug=0"); mWebView.setWebViewClient(new webview()); mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } }); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; registerReceiver(); if (checkPlayServices()) { Intent intent = new Intent(this, ml.hepolise.vkaudiosave.RegistrationIntentService.class); startService(intent); } }
@Implementation public void setDownloadListener(DownloadListener listener) { downloadListener = listener; }
public DownloadListener getDownloadListener() { return downloadListener; }
private void Download_Horario_comp() { // if (month < 8) { // z= ""; //semestre = 1; // semestre_corrente = Integer.toString(semestre); // nome_curso = "engcomputacao"; nome_curso2 = "EngComp"; // url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; url1 = "http://www.iprj.uerj.br/images/images/UERJ_IPRJ_"+nome_curso2+"_Disc_2014_2_p"+numero_periodo+".pdf"; //Toast.makeText(getActivity().getApplicationContext(), url1, Toast.LENGTH_SHORT).show(); WebView webview = (WebView) rootView.findViewById(R.id.webView2); webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF downloadPDF = new DownloadPDF(); downloadPDF.execute(url1,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url1); // } //else { /*semestre = 2; semestre_corrente = Integer.toString(semestre) ; nome_curso = "engcomputacao"; nome_curso2 = "engcomp"; url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; */ /* WebView webview = (WebView) rootView.findViewById(R.id.webView2); webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF downloadPDF = new DownloadPDF(); downloadPDF.execute(url1,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url1); */ // } }
private void Download_Horario_comp2() { // if (month < 8) { // z= ""; //semestre = 1; // semestre_corrente = Integer.toString(semestre); // nome_curso = "engcomputacao"; nome_curso2 = "EngComp"; // url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; url2 = "http://www.iprj.uerj.br/images/images/UERJ_IPRJ_"+nome_curso2+"_Disc_2014_2_p"+numero_periodo2+".pdf"; //Toast.makeText(getActivity().getApplicationContext(), url1, Toast.LENGTH_SHORT).show(); WebView webview = (WebView) rootView.findViewById(R.id.webView1); webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF_2 downloadPDF = new DownloadPDF_2(); downloadPDF.execute(url2,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url2); // } //else { /*semestre = 2; semestre_corrente = Integer.toString(semestre) ; nome_curso = "engcomputacao"; nome_curso2 = "engcomp"; url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; */ /* WebView webview = (WebView) rootView.findViewById(R.id.webView2); webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF downloadPDF = new DownloadPDF(); downloadPDF.execute(url1,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url1); */ // } }
@SuppressLint("SetJavaScriptEnabled") private void Download_Horario_mec() { // TODO Auto-generated method stub //if (month < 8){ //semestre = 1; //semestre_corrente = Integer.toString(semestre); //nome_curso = "engmecanica"; nome_curso2 = "EngMec"; // url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/m%20-%20horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; url1 = "http://www.iprj.uerj.br/images/images/UERJ_IPRJ_"+nome_curso2+"_Disc_2014_2_p"+numero_periodo+".pdf"; // url1 = "http://www.iprj.uerj.br/images/images/UERJ_IPRJ_EngMec_Disc_2014_2_p02.pdf"; // Toast.makeText(getActivity().getApplicationContext(), url1, Toast.LENGTH_SHORT).show(); WebView webview = (WebView) rootView.findViewById(R.id.webView2); webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF downloadPDF = new DownloadPDF(); downloadPDF.execute(url1,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url1); // } //else{ //z= "m - "; //semestre = 2; // semestre_corrente = Integer.toString(semestre); // nome_curso = "engmecanica"; //nome_curso2 = "EngMec"; //url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/m%20-%20horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; // WebView webview = (WebView) rootView.findViewById(R.id.webView2); /* webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF downloadPDF = new DownloadPDF(); downloadPDF.execute(url1,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url1); */ //} }
@SuppressLint("SetJavaScriptEnabled") private void Download_Horario_mec2() { // TODO Auto-generated method stub //if (month < 8){ //semestre = 1; //semestre_corrente = Integer.toString(semestre); //nome_curso = "engmecanica"; nome_curso2 = "EngMec"; // url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/m%20-%20horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; url2 = "http://www.iprj.uerj.br/images/images/UERJ_IPRJ_"+nome_curso2+"_Disc_2014_2_p"+numero_periodo2+".pdf"; // url1 = "http://www.iprj.uerj.br/images/images/UERJ_IPRJ_EngMec_Disc_2014_2_p02.pdf"; // Toast.makeText(getActivity().getApplicationContext(), url1, Toast.LENGTH_SHORT).show(); WebView webview = (WebView) rootView.findViewById(R.id.webView1); webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF_2 downloadPDF = new DownloadPDF_2(); downloadPDF.execute(url2,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url2); // } //else{ //z= "m - "; //semestre = 2; // semestre_corrente = Integer.toString(semestre); // nome_curso = "engmecanica"; //nome_curso2 = "EngMec"; //url1 ="http://iprj.uerj.br/images/arquivos/horarios/"+nome_curso+"/"+year+"-"+semestre_corrente+"/m%20-%20horario-"+numero_periodo+"%C2%BA%20periodo-"+nome_curso2+".pdf"; // WebView webview = (WebView) rootView.findViewById(R.id.webView2); /* webview.setWebViewClient(new WebViewClient()); webview.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { //start download DownloadPDF downloadPDF = new DownloadPDF(); downloadPDF.execute(url1,userAgent,contentDisposition); } }); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl(url1); */ //} }
WebListenerManager setDownLoader(WebView webView, DownloadListener downloadListener);