2

我有一个应用程序,可以从中获取所有已安装应用程序及其图标的列表。这是我的代码:

package com.powergroupbd.appfilter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ApplicationFilterActivity extends Activity {
    /** Called when the activity is first created. */

    ListView appfilter;
    // ArrayAdapter<Applications> adapter;
    PackageManager pck;
     ArrayList<Applications> results = new ArrayList<Applications>();


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        appfilter = (ListView) findViewById(R.id.lvApp);

        PackageManager packageManager = this.getPackageManager();
        List<PackageInfo> applist = packageManager.getInstalledPackages(0);
        Iterator<PackageInfo> it = applist.iterator();
        while (it.hasNext()) {
            PackageInfo pk = (PackageInfo) it.next();
results.add(new Applications(pk.applicationInfo.loadIcon(packageManager), ""+pk.applicationInfo.loadLabel(packageManager)));
            Log.i("AppName", ""+pk.applicationInfo.loadLabel(packageManager));
}

         Collections.sort(results, new Comparator<Applications>() {
         @Override
         public int compare(Applications c1, Applications c2) {
         return c1.getAppname().compareToIgnoreCase(c2.getAppname());
         }
         });

        appfilter.setAdapter(new Customarrayadapter(this, results));
    }
}

但现在我希望如果我点击一个列表项,那么该特定应用程序将从下一次开始以横向打开,我需要想法我该怎么做?

4

1 回答 1

1

我个人的经验是,您尝试做的事情是不可能的。无法从另一个应用程序强制应用程序仅以横向模式显示。如果我对您的理解正确,即使设备处于纵向状态,您也希望以横向模式打开所选应用程序,对吗?

于 2012-06-14T19:23:18.630 回答