- android系统级app获取运行中的内存
这里系统级app指的是安装在system/app
目录下或者system/priv-app
目录下的app,因为google出于安全和隐私的考虑在android5.1之后已经将getRunningAppProcesses()
方法弃用,该方法只能获取当前app,而不能获取所有的运行中的app。系统级的app仍能使用该方法:
ActivityManager actvityManager =(ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> procInfos =actvityManager.getRunningAppProcesses();
StringBuilder sBuilder=new StringBuilder();
System.out.println("procInfos size:"+procInfos.size());
for(RunningAppProcessInfo info:procInfos)
{
sBuilder.append(info.processName+"\n");
}
需要添加权限:`<uses-permission android:name="android.permission.REAL_GET_TASKS" />`
此方法只对系统app有效。
* [如何让Android屏幕只能上下翻转](http://blog.csdn.net/oracleot/article/details/19045011)
<activity
android:name="com.example.kata1.MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
`android:screenOrientation`可以设置的值:
`unspecified,behind,landscape,portrait,reverseLandscape,reversePortrait,sensorLandscape,sensorPortrait,userLandscape,userPortrait,sensor,fullSensor,nosensor,user,fullUser,locked
`
* listview的item的长按事件也会触发点击事件
在实现`listview`的`onItemLongClickListener`的时候,也会触发`onItemClickListener`,这是因为`onItemLongClickListener`实现的时候默认返回值为`false`,返回`true`则不会触发点击事件:
listview.setOnItemLongClickListener(new AdapterView.OnItemClickListener() {
@Override
public boolean onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
// Do something
return true.
}
* [Android源码问题解答之三(状态栏和锁屏)](http://blog.csdn.net/tfslovexizi/article/details/43306939)