屏蔽返回键
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
return true;
}
return super.onKeyDown(keyCode, event);
}
屏蔽home键
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
屏蔽其他实体按键
switch (keyCode) {
case KeyEvent.KEYCODE_HOME:
return true;
case KeyEvent.KEYCODE_BACK:
return true;
case KeyEvent.KEYCODE_CALL:
return true;
case KeyEvent.KEYCODE_SYM:
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
return true;
case KeyEvent.KEYCODE_STAR:
return true;
}
屏蔽home键后全屏消失 说明你是在代码中设置全屏的,转到AndroidManifest.xml设置全屏就行
<activity android:name=".WelcomeActivity" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
(可解决不能同时屏蔽home/back键)
/** Returns the persistent store coordinator for the application. If the coordinator doesn't already exist, it is created and the application's store added to it. */ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator_ != nil) { return persistentStoreCoordinator_; } NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"golf.sqlite"]; NSError *error = nil; persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } return persistentStoreCoordinator_; }
1.获取MD5码,在eclipse:Window-preference-android-build中找到:Debug key store的位置,然后再终端(java环境变量已经配置)输入:
keytool -list -alias androiddebugkey -keystore "/home/smile/.android/debug.keystore" -storepass android -keypass android
然后生成MD5码了:
Certificate fingerprint (MD5): B4:ED:DA:3E:C1:59:7E:A3:0F:D7:EC:A2:CD:A0:0C:07
2.访问http://code.google.com/android/add-ons/google-apis/maps-api-signup.html,输入MD5码,生成key
3. xml文件中:<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0JBFjNUzYoEqDk1aEJaD139r-4zkEtC27X5GHNQ"
/>