在应用中如何去掉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()));
	}





你可能感兴趣的:(在应用中如何去掉hoem键及statusbar)