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

結果圖:

首先介紹一下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. TreeMap的使用

    Map<Integer, String> map = new TreeMap<Integer, String>();//TreeMap本身具有排序功能(默认按键升序排序) ma ...

  2. vmware安装linux6.3

    安装信息: 1.vmware9.0下载地址:http://pan.baidu.com/share/link?shareid=1287299796&uk=2585121485 2.oraclel ...

  3. C#范型不会用,求助~

    using Dapper; using Dapper.Contrib.Extensions; using System.Data.SqlClient; using System.Configurati ...

  4. C# 理解Thread.Sleep()方法 ----转帖

    我们可能经常会用到 Thread.Sleep 函数来使线程挂起一段时间.那么你有没有正确的理解这个函数的用法呢?思考下面这两个问题:1.假设现在是 2008-4-7 12:00:00.000,如果我调 ...

  5. C、C++、Java、go的语法区别

    详细C++.Java比较:http://www.cnblogs.com/stephen-liu74/archive/2011/07/27/2118660.html 一.C.C++的区别 在很大程度上, ...

  6. SQL Server 2008通过LinkServer操作ORACLE

    时光荏苒~~ 最近项目有需求需要通过SQL Server2008中的数据自动更新到ORACLE中,其实,一开始肯定会想到触发器,因为可以保证实时性. 方案一: 首先,我很确定的一件事情就是MSSQL中 ...

  7. which type of VS files should be committed into a version control system

    which type of VS files should be committed into a version control system? aps, no: last resource edi ...

  8. DOM查找元素

    1. 查找元素5种: 1. 按id查找1个元素对象: var elem=document.getElementById("id值"); 何时使用:1. 元素必须有id 2. 精确查 ...

  9. 大前端学习笔记整理【一】CSS盒模型与基于盒模型的6种元素居中方案

    概览 CSS盒模型,规定了元素框来处理元素的 内容.内边距.边框和外边距的方式 元素部分是指内容部分,也是最实际的内容,包围内容的称之为内边距,内边距外围是边框,边框外围就是外边距:且外边距是透明的, ...

  10. .NET J2EE APP全局会话架构运用场景

    .NET J2EE APP全局会话架构运用场景, 全局会话运用拓扑图代码核心架构为.NET架构开发C#语言为主代码架构分为全局会话中心.ASP.NET会话节点..NET会话节点针对WCF服务器与APP ...