分页: 4/220 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]
获取已安装的程序的信息(名称、包名、图标等)

class PInfo {
    private String appname = "";
    private String pname = "";
    private String versionName = "";
    private int versionCode = 0;
    private Drawable icon;
    private void prettyPrint() {
        log(appname + "\t" + pname + "\t" + versionName + "\t" + versionCode + "\t");
    }
}

private void listPackages() {
    ArrayList<PInfo> apps = getInstalledApps(false); /* false = no system packages */
    final int max = apps.size();
    for (int i=0; i<max; i++) {
        apps.get(i).prettyPrint();
    }
}

private ArrayList<PInfo> getInstalledApps(boolean getSysPackages) {
    ArrayList<PInfo> res = new ArrayList<PInfo>();        
    List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
    for(int i=0;i<packs.size();i++) {
        PackageInfo p = packs.get(i);
        if ((!getSysPackages) && (p.versionName == null)) {
            continue ;
        }
        PInfo newInfo = new PInfo();
        newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
        newInfo.pname = p.packageName;
        newInfo.versionName = p.versionName;
        newInfo.versionCode = p.versionCode;
        newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
        res.add(newInfo);
    }
    return res;
}


获取未安装的APK文件的信息
Tags: ,
公司活动安排在泰莲庭,一个环境还不错的地方,拍了几个照片,还可以。

点击在新窗口中浏览此图片

点击在新窗口中浏览此图片

门口的位子,夜晚应该很漂亮舒适

点击在新窗口中浏览此图片

点击在新窗口中浏览此图片

门口的鹦鹉,我很奇怪,它总是咬着笼子的柱子,然后围着笼子四周转圈,看起来很聪明
Tags:
简单的小问题,如果列出了所有安装的程序,怎么样打开该程序呢?

要调用该程序,有两个必要因素:packageName, className
比如打开计算器程序:

Intent i = new Intent();
i.setClassName("com.android.calculator2", "com.android.calculator2.Calculator");
startActivity(i);


前面是packageName,后面是className,我们尝试取出此两个值即可。

List<PackageInfo> packs = getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
for(int i=0;i<packs.size();i++) {
  PackageInfo p = packs.get(i);
  //p.packageName;
  //p.activities[0].name; //(className)
}
Tags: ,
备忘
.test{
width:200px;
height:50px;
border:1px solid red;
padding:10px;
overflow:hidden; /*不显示超过对象宽度的内容*/
text-overflow:ellipsis; /*当对象内文本溢出时显示省略标记(...)*/
white-space:nowrap; /*限制在一行内显示所有文本*/
}
Tags: ,
IIS就是一个灾难,可操作性很差,不悦。。

引用
Request 对象 错误 'ASP 0104 : 80004005'不允许操作 /up/upload.asp,行 20


IIS默认是允许200k的上传,要上传更大,就得修改IIS的配置文件了。

1 打开IIS的属性,允许直接编辑配置数据库,这样不用停止IIS,否则编辑不了配置文件
2 打开 C:\Windows\System32\Inetsrv\metabase.XML
3 修改 ASPMaxRequestEntityAllowed 里的值,比如1024000,10M的大小
4 保存即可
Tags: ,
简单的代码,测试至少是可行
public static void downloadFile(String url, String newPath) {  
  URL myFileUrl = null;  
  try {  
    myFileUrl = new URL(url);  
  } catch (MalformedURLException e) {  
    Log.e("test", "MalformedURLException: "+e.toString() );
  }  
  try {  
    HttpURLConnection conn;
    conn = (HttpURLConnection) myFileUrl.openConnection();
    conn.setDoInput(true);
    conn.connect();  
    InputStream is = conn.getInputStream();  
    FileOutputStream  newfile  =  new  FileOutputStream("/sdcard/tmp.apk");  
    byte[]  buffer  =  new  byte[1444];
    int  byteread  =  0;  
    while  (  (byteread  =  is.read(buffer))  !=  -1)  {  
      newfile.write(buffer,  0,  byteread);  
    }  
    is.close();
  } catch (Exception e) {  
    Log.e("test", "returnNetworkBitMap: "+e.toString() );
  }finally{
  }  
}
Tags:
安装某个apk文件:

String fileName = "/sdcard/tmp.apk";
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(fileName) ), "application/vnd.android.package-archive");
startActivity(i);


注:如果文件不存在会提示解析出错

卸载某个程序:

Uri packageURI = Uri.parse("package:com.aslibra.test");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);


参考阅读:

Install and Uninstall Android applications with PackageInstaller,包含判断是否开启安装第三方程序的支持

另外还有 Android Intent的几种用法全面总结,必要的时候可以参考啦

Tags:
分页: 4/220 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐