当前位置: 首页>>代码示例>>Java>>正文


Java DownloadListener类代码示例

本文整理汇总了Java中android.webkit.DownloadListener的典型用法代码示例。如果您正苦于以下问题:Java DownloadListener类的具体用法?Java DownloadListener怎么用?Java DownloadListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DownloadListener类属于android.webkit包,在下文中一共展示了DownloadListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setDownloadListener

import android.webkit.DownloadListener; //导入依赖的package包/类
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();

    }
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:17,代码来源:AgentWeb.java

示例2: onCreate

import android.webkit.DownloadListener; //导入依赖的package包/类
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());
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:21,代码来源:LetvWebViewActivity.java

示例3: onCreate

import android.webkit.DownloadListener; //导入依赖的package包/类
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) {
                }
            }
        });
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:19,代码来源:LetvSearchWebViewActivity.java

示例4: setDefaultDownloadListener

import android.webkit.DownloadListener; //导入依赖的package包/类
/**
 * 设置下载监听器,默认使用浏览器下载
 */
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);
        }
    });
}
 
开发者ID:chendongMarch,项目名称:uikit,代码行数:22,代码来源:XWebView.java

示例5: createDownloadListener

import android.webkit.DownloadListener; //导入依赖的package包/类
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);
            }
        }
    };
}
 
开发者ID:mozilla-mobile,项目名称:focus-android,代码行数:25,代码来源:SystemWebView.java

示例6: getMimeType

import android.webkit.DownloadListener; //导入依赖的package包/类
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/*";
}
 
开发者ID:hss01248,项目名称:HttpUtilForAndroid,代码行数:24,代码来源:Tool.java

示例7: getDownloadListener

import android.webkit.DownloadListener; //导入依赖的package包/类
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);
       }
    };
}
 
开发者ID:mattermost,项目名称:mattermost-android-classic,代码行数:26,代码来源:WebViewActivity.java

示例8: getDownloadListener

import android.webkit.DownloadListener; //导入依赖的package包/类
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();
            }
        }
    };
}
 
开发者ID:douban,项目名称:rexxar-android,代码行数:18,代码来源:RexxarWebViewCore.java

示例9: init

import android.webkit.DownloadListener; //导入依赖的package包/类
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);
                }
            }
        });
    }
 
开发者ID:whitelaning,项目名称:WhiteRead,代码行数:22,代码来源:MMWebView.java

示例10: onCreate

import android.webkit.DownloadListener; //导入依赖的package包/类
@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());
	
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:HTML5WebViewCustomAD.java

示例11: findView

import android.webkit.DownloadListener; //导入依赖的package包/类
@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);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:InviteWebviewimpl.java

示例12: initWebKit

import android.webkit.DownloadListener; //导入依赖的package包/类
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");
}
 
开发者ID:LiangMaYong,项目名称:android-base,代码行数:30,代码来源:AbstractWebKit.java

示例13: onCreate

import android.webkit.DownloadListener; //导入依赖的package包/类
@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);


}
 
开发者ID:bornbeauty,项目名称:sdnutools,代码行数:36,代码来源:HelpActivity.java

示例14: setDownloadListener

import android.webkit.DownloadListener; //导入依赖的package包/类
@Override
public void setDownloadListener(DownloadListener listener) {
	if (listener == mDefaultDownloadListener) {
		super.setDownloadListener(listener);
	} else {
		mDelegateDownloadListener = listener;
	}
}
 
开发者ID:v7lin,项目名称:Android_Skin_3.x,代码行数:9,代码来源:CompatWebView.java

示例15: onCreate

import android.webkit.DownloadListener; //导入依赖的package包/类
@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);

}
 
开发者ID:Seeed-Studio,项目名称:Wio_Link_Android_App,代码行数:40,代码来源:WebActivity.java


注:本文中的android.webkit.DownloadListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。