2016-04-28 5 views
0

私はロック画面アプリを実装しています。ユーザーはパスコードを入力し、一定期間デバイスをロック解除する必要があります。私は、注3のすべての物理的なボタン1Androidのホームボタンを無効にする

をサムスン注3でテストし、小米科技redmi

がロックされていますが、どういうわけか、私は小米科技redmi 1のホームボタンを無効にすることはできません。 **ホームボタンはonPauseイベントを実行します。

enter image description here

私はコードがlogcatでボタンを表示することができませんでした。

私はonPauseを使用して再度アプリケーションを実行しようとしましたが、応答が遅くなりました。

@Override 
public void onPause() { 
    super.onPause();. 
    Intent intent = new Intent(LockScreenActivity.this, SettingActivity.class); 
    startActivity(intent); 
} 
+0

(http://stackoverflow.com/questions/3898876/how-to-disable-the-home-key)[ホームキーを無効にする方法] –

+0

チェックの可能性の重複これはhttp://stackoverflow.com/questions/3898876/how-to-disable-the-home-key –

答えて

1
Try this overridden method 

@Override 
public void onAttachedToWindow() { 
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); 
    super.onAttachedToWindow(); 
} 


but it's not a good practice to disable home button. 
+0

私はすでに私のアプリでコードを持っている、xiaomi redmi note1のホームボタンを無効にすることはできません、おそらくボタンは特別です... –

1
change laucher 
modify AndroidManifest.xml 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

To: 
-------------------------------------- 
     <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.HOME"/> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <category android:name="android.intent.category.MONKEY" /> 
     </intent-filter> 
関連する問題