最近會用到,簡單記錄一下,抓取所有該手機已經安裝的軟體清單

結果圖:

首先介紹一下Layout :  \Resources\Layout\Main.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
        android:id="@+id/btnGetAllList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="取得所有APPS" />
    <ScrollView
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView1">
        <LinearLayout
            android:orientation="vertical"
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/linearLayout1" />
    </ScrollView>
</LinearLayout>

預覽:

按下按鈕(btnGetAllList)後 會將所有安裝過的軟體名稱放入至按鈕下方的LinearLayout(linearLayout1)中,因為怕很多所以有用ScrollViewer包起來

接下來就是 C# Code 部分:

using Android.App;
using Android.Content.PM;
using Android.Graphics;
using Android.Widget;
using Android.OS;
 
namespace GetAllAppList
{
    [Activity(Label = "取得所有app清單", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
 
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
 
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
 
            var btnGetAllList = FindViewById<Button>(Resource.Id.btnGetAllList);
            var appContainer = FindViewById<LinearLayout>(Resource.Id.linearLayout1);
 
 
            //取得所有APPS 按鈕事件
            btnGetAllList.Click += delegate
                {
 
                    var appLists = PackageManager.GetInstalledPackages(PackageInfoFlags.Activities);
                    Toast.MakeText(this, "發現已安裝數量:" + appLists.Count + "", ToastLength.Long).Show();
 
                    //清空容器
                    appContainer.RemoveAllViews();
 
 
                    foreach (var resolveInfo in appLists)
                    {
                        var t = new TextView(this);
                        //設定顏色 看起來比較geek
                        t.SetTextColor(new Color(0, 255, 0));
                        t.Text = resolveInfo.PackageName;
                        appContainer.AddView(t);
                    }
                };
        }
    }
}
 

重點在這一行:

var appLists = PackageManager.GetInstalledPackages(PackageInfoFlags.Activities);

結果預覽:

[Xamarin] 取得所有已安裝軟體清單 (转帖)的更多相关文章

  1. FreeBSD利用 ports 來安裝軟體

    FreeBSD利用 ports 來安裝軟體   利用 ports 來安裝軟體 FreeBSD 的 ports 就是別人已經編譯過,安裝測試沒問題了,他們將軟體編譯時所需的組態設定.編譯程序及安裝程序, ...

  2. FreeBSD 安裝 Tomcat JAVA JDK1.6 筆記

    首先是安裝軟體 cd /usr/ports/java/jdk16/ make 在這一步,需要你手動到sun.com上下載幾個安裝包,按提示下載好後加入到 /usr/ports/distfiles/,再 ...

  3. 鸟哥之安裝 CentOS7.x

    http://linux.vbird.org/linux_basic/0157installcentos7.php since 2002/01/01 新手建議 開始閱讀之前 網站導覽 Linux 基礎 ...

  4. [SharePoint 2010] 如何安裝啟用多國語系支援的SharePoint網站

    SharePoint 2010的多國語系支援與前一版的SharePoint 2007有所不同,SharePoint 2010內允許使用者自行決定使用介面語系的選擇. SharePoint 2010的多 ...

  5. kali 安裝虛擬機VMware

    0x00前言 由於之前已經安裝過虛擬機,這次爲了寫博客又重新安裝了一邊,有些地方直接按照之前的默認的設置來了,省了設置,中間又換了一個實驗環境.完成了文章中的演示,整個過程多次實驗是沒問題的,若有疑問 ...

  6. 在VPS上安裝BT軟體Transmission

    在VPS上安裝BT軟體Transmission   作者: 窮苦人家的小孩 | 2009-12-04 55 Comments   VPS 還能怎玩?! 裝Proxy,裝VPN,這還不夠,我還用來掛種子 ...

  7. 安裝開源BBS軟件YAF時碰到的問題

    1.下載 http://yetanotherforum.net/download.aspx 安裝說明 http://www.drreddys.com/quest/readme.htm 其實只要打開根目 ...

  8. Darwin Streaming Server 安裝操作備忘

    Darwin Streaming Server 安裝操作 Darwin Streaming Server是蘋果公司推出的開放源碼.跨平台多媒體串流伺服器, 提供音樂 (mp3) 與影音 (3gp.mp ...

  9. VPN Gate Client v4.11-免費、無限流量VPN翻牆(跳板)軟體(使用教學)

    VPN Gate Client安裝教學 ▼把下載的檔案壓縮後,開啟安裝檔案. ▼接下來就是一般安裝步驟,下一步>下一步   ▼同意>下一步>下一步   ▼安裝目錄可以用預設的也可以自 ...

随机推荐

  1. Ubuntu 安装tftp服务器

    Ubuntu下搭建tftp服务器最简单方法   转 linux公社       今天开始调试ARM的板子,要通过tftp下载到板子上,所以又要配置tftp服务器,真的烦死了... (本人酷爱装系统,所 ...

  2. CSS浏览器兼容问题总结

    为什么会出现浏览器兼容问题? 由于各大主流浏览器是不同的厂家开发的,所以使用的核心也不相同,架构代码很难重合,就会产生各种各样的bug. IE6中常见的css解析bug 1)默认高度(IE6)部分块元 ...

  3. IOS 代码提示有问题

    Window(menu) -> Organizer(menu) -> Projects(tab) 删除 Derived Data ,立刻关闭xcode 然后重启xcode然后重新打开项目.

  4. 后台返回字符串类型function的处理 (递归算法)

    $(function(){ $.ajax({ type: "post", url: "${ctx}/modules/fos/reference/echart", ...

  5. PhpStorm破解教程

    http://www.cnblogs.com/buyucoder/p/5291771.html

  6. C语言小练习四

    题目要求:输入N个数,输出该数列中第k个最大者. 程序源码: #include <stdio.h> #include <string.h> void printResult(i ...

  7. Android studio 分析内存泄漏

    以前用eclipse的时候,我们采用的是DDMS和MAT,不仅使用步骤复杂繁琐,而且要手动排查内存泄漏的位置,操作起来比较麻烦.后来随着Android studio的潮流,我也抛弃了eclipse加入 ...

  8. 用eclipse搭建SSH(struts+spring+hibernate)框架

    声明: 本文是个人对ssh框架的学习.理解而编辑出来的,可能有不足之处,请大家谅解,但希望能帮助到大家,一起探讨,一起学习! Struts + Spring + Hibernate三者各自的特点都是什 ...

  9. Ubuntu-14.04.3下SDL2测试

    最近突然蛋痛想入门Linux,想写个跨平台的游戏,各种坑,备忘,稍微记点笔记. 主要参考这个文章 buntu14.04下C++开发SDL2应用 下载与安装 到http://www.libsdl.org ...

  10. svn+ssh方式svn服务器和客户端的配置[转载]

    本文摘自:http://hi.baidu.com/farmerluo/item/e7d9d72d098afc0a42634abb 我们最近一个项目用的那几台服务器都是客户给的,但是管理非常严格,只给我 ...