另类方法屏蔽Android4.03的HOME按键
2013-03-13 15:25
204 查看
<activity android:name="com.XXX.android.system.EmptyHome" android:label="@string/app_name" android:theme="@android:style/Theme.NoDisplay" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.HOME" /> </intent-filter> </activity>
package com.XXX.android.system; import java.util.List; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.widget.Toast; /** * 有了厂家的支持,放弃此另类屏蔽HOME键做法。 * * @author AsionTang * @date 2013年3月13日 14:48:44 */ @Deprecated public class EmptyHome extends Activity { public static boolean isExited = true; @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (isExited) { final PackageManager packageManager = this.getPackageManager(); final Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); final List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (int i = 0; i < list.size(); i++) { final String name = list.get(i).activityInfo.packageName; if (!"EmptyHome".equals(name)) { intent.setPackage(name); break; } } this.startActivity(intent); Toast.makeText(this, "HOME", Toast.LENGTH_SHORT).show(); } this.finish(); } }
相关文章推荐
- 如何在Android App中屏蔽(拦截)Home按键及其他按键
- android 4.0以上屏蔽HOME按键
- Android4.3 屏蔽HOME按键返回桌面详解(源码环境下)
- Android4.0以后屏蔽以及HOME按键事件拦截
- android屏蔽返回键和home键等各个按键的方法
- Android4.3 屏蔽HOME按键返回桌面详解(源码环境下)
- Android 按键屏蔽, Back, Home....
- Android4.3 屏蔽HOME按键返回桌面详解(源码环境下)
- Android 屏蔽 Home 按键
- 2017.9.15 android 屏蔽home按键
- 如何在Android App中屏蔽(拦截)Home按键及其他按键
- android如何屏蔽home back power按键(现保存以后很可能会需要的)
- 如何在Android App中屏蔽(拦截)Home按键及其他按键
- Android 屏蔽recent按键 ,Home按键,Recent按键的监听可以用广播,还有开机启动app
- Android屏蔽Home按键
- Android App中屏蔽(拦截)Home按键及其他按键
- android屏蔽返回键和home键等各个按键的方法
- android4.1 activity内屏蔽HOME按键功能
- Android 小米盒子游戏手柄按键捕获 - 能获取到的 home 键依然是个痛
- Android 实现模拟按键方法二