我怎样才能得到所有已安装的应用程序的列表

我怎样才能得到所有已安装的应用程序的列表

本文介绍了我怎样才能得到所有已安装的应用程序的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!我希望收到在Android建立的附录名单。但该列表仅在LogCat中显示。怎么写,它被显示在手机?
我用给定的code:
Java的:

Greetings! I want to receive the list of the established appendices in the Android. But the list is displayed only in LogCat. How to write, that it was displayed on phone?I use the given code:java:

package com.tipfile;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

public class dop extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PackageManager pm = this.getPackageManager();

    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    ArrayList<ResolveInfo> list = (ArrayList<ResolveInfo>)
    pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
    for (ResolveInfo rInfo : list) {
    System.out.println("Installed Applications "  + rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
    }}}

XML:

<?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">
<TextView
    android:id="@+id/textSelest"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textStyle="bold"/>
<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="false"/>
</LinearLayout>

译者通过网上写道。我不知道英语。

推荐答案

使用 getInstalledPackages()

List pkgAppsList = context.getPackageManager().getInstalledPackages();

http://developer.android.com/reference/android/content/pm/PackageManager.html#getInstalledPackages%28int%29

这篇关于我怎样才能得到所有已安装的应用程序的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 20:51