如何获得Android设备上安装的所有应用程序的列表 [英] How to get a list of all installed apps on a android device

查看:226
本文介绍了如何获得Android设备上安装的所有应用程序的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我上有类似的用户界面MIUI首页一个应用程序的工作,但是我不知道如何让应用程序的显示设备上的所有安装的应用程序

hello I am working on a app that has a similar UI to MIUI Home however I don't know how to have the app display all installed apps on the device

这是我的code:

package com.d4a.tobias;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class SpringboardActivity extends Activity {

    public static final String LOGTAG = "Springboard";
    private final String TAG = "SpringboardActivity";

    private RelativeLayout mRlRoot;
    /*private RelativeLayout mRlFullGrid;
    private RelativeLayout mRlTabBar;
    private DragView mDragView;
    private DragViewTabBar mDragViewTabBar;*/
    private DraggableView mDragView;
    private LayoutInflater mInflater;

//  private ArrayList<View> mGridItems;

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

        Log.i(LOGTAG, TAG + " - onCreate");

        mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        mRlRoot = (RelativeLayout) findViewById(R.id.sb_RlRoot);
//        mDragView = new DragView(this);
        mDragView = new DraggableView(this);
//        mDragViewTabBar = new DragViewTabBar(this);
        mRlRoot.addView(mDragView);
//        mRlRoot.addView(mDragViewTabBar);
    }





    @Override
    protected void onStart() {
        super.onStart();
        Log.i(LOGTAG, TAG + " - onStart");

        addItemsToGridView();
//      addItemsToTabBar();
    }

    private void addItemsToGridView() {
        mDragView.setGridViewCount(10);
        for (int i = 0; i < 14; i++) {
            View view = mInflater.inflate(R.layout.one_item, null);
            ImageView ivIcon = (ImageView) view.findViewById(R.id.ivIcon);
            TextView tvIcon = (TextView) view.findViewById(R.id.tvIcon);
            tvIcon.setText("EG "+i);
            int childSize = mDragView.getChildSize();
            ivIcon.setBackgroundResource(R.drawable.chrome_icon);
            LinearLayout.LayoutParams ivParams = (LinearLayout.LayoutParams) ivIcon.getLayoutParams();
            ivParams.width = childSize / 2;
            ivParams.height = childSize / 2;
            ivIcon.setLayoutParams(ivParams);
            mDragView.addViewToLayout(view, i, new LayoutParams(childSize, childSize));
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.springboard, menu);
        return true;
    }
}

我已经试过这goggling 1日,但没有运气
我真的很强调在这个

I have tried goggling this 1st but no luck I am really stressing over this

任何帮助将是惊人的!

在此先感谢!

推荐答案

要获得所有已安装的应用程序列表

To get a list of all the installed apps

  final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);

这篇关于如何获得Android设备上安装的所有应用程序的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆