Ejemplo n.º 1
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    // TODO Auto-generated method stub
    Uri uri =
        Uri.parse(
            moeapk.ApkDownloadUrl(
                app_package,
                moeapk.current_apklist_vcode[position],
                moeapk.current_apklist_special[position]));
    // Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    // startActivity(intent);

    DownloadManager mgr = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    DownloadManager.Request request = new DownloadManager.Request(uri);
    request.setDestinationInExternalPublicDir(
        "MoeApk",
        moeapk.current_apklist_appname[position]
            + "_"
            + moeapk.current_apklist_vname[position]
            + "_"
            + moeapk.current_apklist_sname[position]
            + ".apk");
    request.setAllowedNetworkTypes(
        DownloadManager.Request.NETWORK_MOBILE
            | DownloadManager.Request.NETWORK_WIFI); // 允许流量和wifi使用
    request.setAllowedOverRoaming(false); // 不允许在漫游时下载
    request.setMimeType("application/vnd.android.package-archive");
    request.setTitle(moeapk.current_apklist_appname[position]);
    request.setDescription("来自萌萌安卓的下载");
    request.setVisibleInDownloadsUi(true);
    long downloadid = mgr.enqueue(request);
    Toast.makeText(
            getApplicationContext(), "文件将保存在" + fileUtils.SDCARD + "MoeApk下", Toast.LENGTH_LONG)
        .show();
  }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_index);

    localinfo = new LocalInfo(this);

    // 活动管理器
    ActivityManager.getInstance().addActivity(IndexActivity.this);

    // 绑定列表样式
    index_listview = (ListView) findViewById(R.id.index_list);

    // 设定点击监听器
    index_listview.setOnItemClickListener(this);

    MoeApkSetEditor = this.getSharedPreferences(MoeApk_PREF_NAME, 2).edit();
    MoeApkSetReader = this.getSharedPreferences(MoeApk_PREF_NAME, 1);

    // 获取分类
    list_item = moeapk.App_Type;

    // 制造列表
    ThreadGetList();
    FirstStart();
    // 向API服务器报告一次运行了这个客户端
    moeapk.registerClient(DeviceId);
  }