-1
问候!我想要获得Android中已建立的附录列表。但是列表仅在LogCat中显示。如何写,它显示在手机上? 我用给定的代码: 的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>
译者通过网上写道。我不懂英语。
的代码没有问题显示在logcat中。那么在电话中显示它,它是如何制作的? – ghostged 2011-05-07 07:28:10
帮助!所有的黑屏都一样。因为有必要添加代码。谢谢。 – ghostged 2011-05-16 10:30:55