当前位置: 首页 > news >正文

网络营销课程大概学什么内容如何优化标题关键词

网络营销课程大概学什么内容,如何优化标题关键词,抖音代运营方案范文,应该符合建设网站原文:http://blog.csdn.net/jasper_success/article/details/7984065 第一步:使用java.net的URLConnection对象来创建连接 第二步:通过InputStream将下载的文件写入存储卡内缓存 第三步:下载完毕之后,通过自定义的open…

原文:http://blog.csdn.net/jasper_success/article/details/7984065

第一步:使用java.net的URLConnection对象来创建连接

第二步:通过InputStream将下载的文件写入存储卡内缓存

第三步:下载完毕之后,通过自定义的openFile()方法打开文件,判断文件类型,若为APK,开始安装

第四步:准备离开Installer程序的同时,通过自制的delFile()方法,删除缓存内文件

 

/*** 远程下载安装Android程序* * @ClassName InstallOnlineActivity* @author Jet* @date 2012-9-14*/
public class InstallOnlineActivity extends Activity {private TextView mTextView;private EditText mEditText;private Button mButton;private String currentFilePath = "";private String currentTempFilePath = "";private String strURL = "";private String fileEx = "";private String fileName = "";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.installonline);mTextView = (TextView) findViewById(R.id.installonline_text1);mEditText = (EditText) findViewById(R.id.installonline_edittext1);mButton = (Button) findViewById(R.id.installonline_button1);mButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// 将文件下载到本地mTextView.setText("下载中...");strURL = mEditText.getText().toString();// 截取文件后缀fileEx = strURL.substring(strURL.lastIndexOf('.') + 1,strURL.length()).toLowerCase();// 截取文件名fileName = strURL.substring(strURL.lastIndexOf('/') + 1,strURL.lastIndexOf('.'));getFile(strURL);}});}private void getFile(final String strPath) {if (currentFilePath.equals(strPath)) {getDataSource(strPath);}currentFilePath = strPath;Runnable r = new Runnable() {@Overridepublic void run() {getDataSource(strPath);}};new Thread(r).start();}private void getDataSource(String url) {if (!URLUtil.isNetworkUrl(url)) {mTextView.setText("请填写正确的URL");} else {try {URL myUrl = new URL(url);// 取得连接URLConnection conn = myUrl.openConnection();// 连接
                conn.connect();// 获得输入流InputStream is = conn.getInputStream();if (is == null) {throw new RuntimeException("stream is null");}// 创建临时文件File myTempFile = File.createTempFile(fileName, "." + fileEx);// 取得临时文件存放路径currentTempFilePath = myTempFile.getAbsolutePath();FileOutputStream fos = new FileOutputStream(myTempFile);byte[] buf = new byte[128];do {// 返回现在所读缓冲区的大小int numread = is.read(buf);if (numread <= 0) {break;}fos.write(buf, 0, numread);} while (true);// 打开文件进行安装
                openFile(myTempFile);is.close();} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}}private void openFile(File file) {Intent intent = new Intent();intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.setAction(android.content.Intent.ACTION_VIEW);String type = getMimeType(file);intent.setDataAndType(Uri.fromFile(file), type);startActivity(intent);}private String getMimeType(File file) {String type = "";String fname = file.getName();// 获得扩展名String end = fname.substring(fname.lastIndexOf('.') + 1, fname.length()).toLowerCase();// 按扩展名的类型决定MimeTypeif ("m4a".equals(end) || "mp3".equals(end) || "mid".equals(end)|| "xmf".equals(end) || "ogg".equals(end) || "wav".equals(end)) {type = "audio";} else if ("3gp".equals(end) || "mp4".equals(end)) {type = "video";} else if ("jpg".equals(end) || "gif".equals(end) || "png".equals(end)|| "jpeg".equals(end) || "bmp".equals(end)) {type = "image";} else if ("apk".equals(end)) {type = "application/vnd.android.package-archive";} else {type = "*";}if ("apk".equals(end)) {} else {type += "/*";}return type;}private void delFile(String fileName){File file = new File(fileName);if(file.exists()){file.delete();}}@Overrideprotected void onPause() {mTextView = (TextView) findViewById(R.id.installonline_text1);mTextView.setText("下载成功");super.onPause();}@Overrideprotected void onResume() {//删除临时文件
        delFile(currentTempFilePath);super.onResume();}
}

 

http://www.lbrq.cn/news/2672785.html

相关文章:

  • excel小程序商店seo网络推广案例
  • 开o2o网站需要什么手续百度一下官方网站
  • 新泰网站制作公司短视频推广引流方案
  • 一个月做网站建网站需要什么
  • 网站是用什么程序做的网络运营和网络营销的区别
  • 餐饮公司 网站建设seo外包靠谱
  • 手机app制作网站北大青鸟职业技术学院简介
  • 顾村网站建设无货源网店怎么开
  • 凡科互动游戏玩高分技巧宁波seo网络推广
  • 网站建设佰金手指科杰二八百度查重
  • 杭州网站开发制作公司排名外贸网站制作
  • 宝鸡做网站的简述优化搜索引擎的方法
  • 100个网络营销案例临沂seo推广
  • php网站开发 实战教程网球新闻最新消息
  • 餐饮企业网站建设方案书抖音seo推广外包公司好做吗
  • 模板网站和定制网站后缀的区别软文有哪几种类型
  • 宁波专业做网站的公司哪家好深圳开发公司网站建设
  • 郑州做企业网站hao123网址之家官网
  • 南昌企业制作网站设计seo优化内容
  • 老虎机网站制作网络推广有前途吗
  • 网站 开发 工具网络整合营销推广
  • 网站推广渠道关键词优化怎么操作
  • 单片机做网站云推广
  • 宜昌建网站seo搜索推广费用多少
  • 杭州好的做网站公司谷歌广告推广网站
  • 沈阳哪个网站建设公司好app开发费用
  • 数学建模代做网站app推广联盟平台
  • 常德做网站的公司今日大事件新闻
  • 焦作市建设银行网站会计培训机构排名
  • wordpress主题模板文件下载windows优化大师官方网站
  • 深度学习和神经网络最基础的mlp,从最基础的开始讲
  • 强化学习常用数据集
  • 【图像处理基石】UE输出渲染视频,有哪些画质相关的维度和标准可以参考?
  • 缓存的三大问题分析与解决
  • 未来物联网大模型:物联网硬件+底层驱动+AI 自动生成和调优LUA脚本,
  • Java集合框架、Collection体系的单列集合