26、获取软件信息(包括Lable和相应的应用程序的包名)
来源:互联网 发布:人工智能能否取代老师 编辑:程序博客网 时间:2024/05/17 12:04
------------------------main.java-------------------------
package com.example.software;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import android.app.ProgressDialog;
import android.content.pm.ApplicationInfo;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
/**
* 获取已经安装的软件名及其软件的包名,该包名可以被用来开启另一个应用程序
* @author Administrator
*
*/
public class MainActivity extends ActionBarActivity implements Runnable{
List<Map<String, Object>> list = null;
ListView itemlist = null;
private ProgressDialog pd;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
setTitle("软件信息");
itemlist = (ListView) findViewById(R.id.itemlist);
pd = ProgressDialog.show(this, "请稍候..", "正在收集你已经安装的软件信息...", true,
false);
Thread thread = new Thread(this);
thread.start();
}
private void refreshListItems() {
list = fetch_installed_apps();
SimpleAdapter notes = new SimpleAdapter(this, list, R.layout.info_row,
new String[] {"name", "desc" }, new int[] {R.id.name,
R.id.desc });
itemlist.setAdapter(notes);
//设置actionBar的标题!!
setTitle("软件信息,已经安装"+list.size()+"款应用.");
}
public List fetch_installed_apps(){
List<ApplicationInfo> packages = getPackageManager().getInstalledApplications(0);
list = new ArrayList<Map<String, Object>>(
packages.size());
Iterator<ApplicationInfo> l = packages.iterator();
while (l.hasNext()) {
Map<String, Object> map = new HashMap<String, Object>();
ApplicationInfo app = (ApplicationInfo) l.next();
String packageName = app.packageName;
String label = "";
try {
label = getPackageManager().getApplicationLabel(app).toString();
} catch (Exception e) {
Log.i("Exception",e.toString());
}
map = new HashMap<String, Object>();
map.put("name", label);
map.put("desc", packageName);
list.add(map);
}
return list;
}
@Override
public void run() {
fetch_installed_apps();
handler.sendEmptyMessage(0);
}
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
refreshListItems();
pd.dismiss();
}
};
}
。。。。。。。。。。。。main.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">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/itemlist" />
</LinearLayout>
。。。。。。。。。info_row.xml。。。。。。。。。。。。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vw1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="4px"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/name"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/desc"
android:textSize="14sp"
android:layout_width="fill_parent"
android:paddingLeft="20px"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
- 26、获取软件信息(包括Lable和相应的应用程序的包名)
- 36、获取应用程序图标和相应的软件名,用GridView方式展现
- Android根据包名获取应用程序的信息
- (获取应用的包名/应用名等信息)打开、安装和卸载应用
- 通过包名获取应用程序的名称
- 获取手机中应用程序的包名
- PHP读取APK的包信息,包括包名,应用名,权限,LOGO等
- MonkeyRunner_获取应用程序(apk包)的版本信息
- 获取手机第三方应用的信息(名称,包名,版本号,版本名,安装包路径,安装包大小)
- APK反编译修改包名及相应的基础文件信息
- Android 根据包名,获取应用程序的签名
- Android 根据包名,获取应用程序的签名
- 修改应用程序的包名
- Android获取apk的版本及包名等信息
- Android获取apk的版本及包名等信息
- 获取手机已安装应用的包名等信息
- Android获取apk的版本及包名等信息
- Android中获取应用程序(包)的信息-----PackageManager的使用
- 二叉树链式存储及前序遍历
- 《从0到1》读书笔记第9章“基础决定命运”第1记: 三权主义
- Linux 系统启动过程详解
- Shell基础
- machine_learning神经网络
- 26、获取软件信息(包括Lable和相应的应用程序的包名)
- 栋栋晓03:什么是web标准?
- 从今天开始我遇到所有问题及解决办法我都要写博客了
- Android数据库ORMlite框架翻译系列(第一章)
- 第六课 画图板 lesson 03 第三版 (优化功能:铅笔)
- linux静态库和动态库的简单例子
- mysql手册中值得注意的知识点
- man 命令的详细用法
- CSDN Code Git设置和项目初始化