android 日常(十)

2016-08-22  本文已影响136人  ncd

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)
上一篇下一篇

猜你喜欢

热点阅读