android 结束进程

Android获取apk的版本及包名等信息
http://blog.sina.com.cn/s/blog_49f485700100qk10.html

super.onCreate(savedInstanceState);      
        setContentView(R.layout.main);   
        String archiveFilePath="sdcard/download/Law.apk";//安装包路径
        PackageManager pm = getPackageManager(); 
        PackageInfo info = pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_ACTIVITIES); 
        if(info != null){ 
            ApplicationInfo appInfo = info.applicationInfo; 
            String appName = pm.getApplicationLabel(appInfo).toString(); 
            String packageName = appInfo.packageName;  //得到安装包名称
            String version=info.versionName;       //得到版本信息    
            Toast.makeText(test4.this, "packageName:"+packageName+";version:"+version, Toast.LENGTH_LONG).show();
            Drawable icon = pm.getApplicationIcon(appInfo);//得到图标信息
            TextView tv = (TextView)findViewById(R.id.tv); //显示图标
            tv.setBackgroundDrawable(icon);



-------------------------------

Android 结束进程的方法

http://blog.csdn.net/xwl617756974/article/details/7603725

http://blog.csdn.net/ramondlee/article/details/6840161



manager.killBackgroundProcesses(getPackageName());
[java] view plaincopyprint?

    ActivityManager manager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);        
    manager.killBackgroundProcesses(getPackageName());   


[html] view plaincopyprint?

    //需要在xml中加入权限声明     
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>  

你可能感兴趣的:(android)