随笔 - 91,  文章 - 0,  评论 - 1,  阅读 - 87621

 

复制代码
  private void updateInstalledApps(){
    PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
    ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
    if (PackageInfoList.size() != 0){
      for (PackageInfo info : PackageInfoList){
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("myListViewTextView1", info.packageName); // 应用包名
        // 有权限 可取得应用的安装目录,没有权限则无法获得
        map.put("myListViewTextView2", info.applicationInfo.publicSourceDir);
        // 第一次安装时间
        map.put("myListViewTextView2", convertDateTime(info.firstInstallTime));
        // 最后一次更行时间
        map.put("myListViewTextView3", convertDateTime(info.lastUpdateTime));
        listItem.add(map);
      }
      SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItem, R.layout.list_item_2, new String[] {"myListViewTextView1", "myListViewTextView2", "myListViewTextView3"}, new int[] {R.id.myListViewTextView1,R.id.myListViewTextView2,R.id.myListViewTextView3});
      mListView01.setItemsCanFocus(true);
      mListView01.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
      mListView01.setAdapter(listItemAdapter);
    }
    else{
      mTextView01.setText("No Package Found.");
    }
  }
复制代码

 

复制代码
  public String convertDateTime(long timeStamp){
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date(timeStamp));
    StringBuffer strTmp = new StringBuffer();

    strTmp.append(calendar.get(Calendar.YEAR));
    strTmp.append('.');
    strTmp.append(calendar.get(Calendar.MONTH) + 1);
    strTmp.append('.');
    strTmp.append(calendar.get(Calendar.DAY_OF_MONTH));

    strTmp.append(' '); 
    strTmp.append(calendar.get(Calendar.HOUR_OF_DAY));
    strTmp.append(':');
    strTmp.append(calendar.get(Calendar.MINUTE));
    strTmp.append(':');
    strTmp.append(calendar.get(Calendar.SECOND));
    return strTmp.toString();
  }
复制代码

 

posted on   道无涯  阅读(554)  评论(0编辑  收藏  举报
(评论功能已被禁用)

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示