0
幫助!所有的黑屏都一樣。因爲有必要添加代碼。謝謝。 我用這樣的代碼:如何獲取所有安裝的應用程序列表?
package com.tipfile;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
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);
setContentView(R.layout.dop);
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());
}
ListView listView = (ListView) findViewById(R.id.list);
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1);
listView.setAdapter(aa);
}}