androidf学习之获得包相关信息

判断横竖屏:

int mCurrentOrientation = getResources().getConfiguration().orientation;
           if ( mCurrentOrientation == Configuration.ORIENTATION_PORTRAIT ) { 
        	   // If current screen is portrait
        	           } else if ( mCurrentOrientation == Configuration.ORIENTATION_LANDSCAPE ) {
        	   //If current screen is landscape
        	            }

 

获得包信息

PackagesInfo packageInfo=new PackagesInfo(MyActivity.this);

ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
//获得运行的信息
List<RunningAppProcessInfo> list2 = am.getRunningAppProcesses();
//应用信息,runinfo 是list2中的一个

ApplicationInfo appinfo=packageInfo.getInfo(runinfo.processName);
//获得activityName
pkginfo.activities[0].name

 

你可能感兴趣的:(android)