Android系统自带下载应用的程序,如果需要写下载软件的程序时,可看情况考虑直接调用系统自带的下载程序。

                               

public void download(Context context, String url) {if (url != null) {Intent intent = new Intent(Intent.ACTION_VIEW);Uri data = Uri.parse(Html.fromHtml(url).toString());intent.setData(data);intent.setPackage("com.google.android.browser");intent.addCategory("android.intent.category.BROWSABLE");intent.setComponent(new ComponentName("com.android.browser","com.android.browser.BrowserActivity"));startActivity(intent);}}


这里有一个地方要注意,即我们建的工程要选择Google APIs[Android xx],不要选择Android xx

                           

另外这个方法我在一款机器上测试的时候,一直通不过,出现异常

但是在其它机器上测试都是OK,找不到是什么情况。

更多相关文章

  1. Android 自动化测试—robotium(八)拖拽
  2. Android AM命令行启动程序的方法
  3. Unity接入Android广告: 二、将Aar包放入Unity中测试
  4. Android 程序退出的办法
  5. Android review Android中的测试
  6. android4.3应用程序隐藏状态栏和标题栏
  7. 一、 Android完全退出应用程序

随机推荐

  1. Android(安卓)ApiDemo 笔记(二)Graphics和V
  2. Android(安卓)OpenGL ES和OpenGL一起学(二
  3. Android(安卓)访问本地 HTML
  4. android手机震动代码
  5. android studio出现 waiting for adb
  6. 安卓开发06:布局-线性布局 LinearLayout
  7. Android第三个功能:将文件保存到程序内部
  8. android ListView上拉加载更多 下拉刷新
  9. android长按弹出对话框
  10. Android开发,在Activity启动时,默认隐藏软