zoukankan      html  css  js  c++  java
  • 另类方法屏蔽Android4.03的HOME按键

            <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();
        }
    }
    

      

    作者:Asion Tang
    凡是没有注明[转载]的文章,本Blog发表的文章版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    IOS 网络编程 + 后台保持连接
    iOS 通过代码关闭应用程序
    iOS 委托和协议区别和联系
    对于WIFI版ipad(无GPS芯片)定位功能的释疑
    iOS单例
    svn不能添加.a文件的解决方法
    mac下SVN上传.a静态库文件
    iOS7 兼容及部分细节
    app被Rejected 的各种原因翻译
    iOS 沙盒购买,弹出“需要验证”,“继续登录”的问题?
  • 原文地址:https://www.cnblogs.com/AsionTang/p/2957718.html
Copyright © 2011-2022 走看看