在应用中如何去掉hoem键及statusbar

现在正在做的一个小project 是第一次开机的时候显示一个license,不点击接受的时候 是什么也操作不了的;

好了 直接上代码:manifest如下

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.lenovo.license"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="10" />
	<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
	<uses-permission android:name="android.permission.STATUS_BAR" />
	<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".LenovoOOBEActivity"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.Translucent">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <!-- <category android:name="android.intent.category.LAUNCHER" /> -->
            </intent-filter>
        </activity>
        <receiver android:name=".LicenseOOBEReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.dxt" />
            </intent-filter>
    	</receiver>
    </application>
</manifest>

Activity代码如下:主要是在onresume里面进行屏蔽掉,千万记得不用的时候一定要还原回来,我这里是在onDestory'里面还原的

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE); 
        getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN);  
        setContentView(R.layout.main);
        lenvoDialogActivity = this;
        licenseDialog = new LicenseOOBE(this);
        licenseDialog.setCancelable(false);
        licenseDialog.show();
    }     
   
    protected void onPause(){
		super.onPause();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		try {
            StatusBarManager statusBar = (StatusBarManager) 
                    getSystemService(Context.STATUS_BAR_SERVICE);
            statusBar.disable(StatusBarManager.DISABLE_MASK);
        } catch (Exception e) {
            // Just in case
        }
		super.onResume();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		try {
            StatusBarManager statusBar = (StatusBarManager) 
                    getSystemService(Context.STATUS_BAR_SERVICE);
            statusBar.disable(StatusBarManager.DISABLE_NONE);
        } catch (Exception e) {
            // Just in case
        }
		super.onDestroy();
	}
	

好了看看接受的receive


public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		Log.d("dxt", "1//"+DateFormat.format("mm-dd:kk-mm-ss", System.currentTimeMillis()));
		if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
			mContext = context;
			if (mPreferences == null) {
				mPreferences = context.getSharedPreferences(LICENSEOOBERECEIVER_PREFERENCES, Context.MODE_WORLD_WRITEABLE);
			}

			if (mPreferences.getBoolean(LICENSEOOBERECEIVER_PREFERENCES_KEY,true)) {
				Intent mIntent = new Intent();
				mIntent.setClassName("com.lenovo.license","com.lenovo.license.LenovoOOBEActivity");
				mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				mContext.startActivity(mIntent);
			}
		}
		Log.d("dxt", "2//"+DateFormat.format("mm-dd:kk-mm-ss", System.currentTimeMillis()));
	}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值