携帯電話の特定のセキュリティ機能が有効になっているかどうかをテストする Android アプリを作成しています。たとえば、パスワード ログインが有効になっている場合や、電話でデータが暗号化されている場合などです。
何らかの理由で、これらのセキュリティ機能が電話で有効になっているかどうかをテストして確認するために、アプリを 2 回実行する必要があります。これが私が解決しようとしている問題です。アプリの作成時と、アプリを 2 回目に実行するときではなく、最初に実行するときに、セキュリティ機能が有効になっているかどうかをテストして確認したいと思います。
onStart()
ファイル内の関数でこれらの機能が有効になっているかどうかをテストしMainActivity
ます。以下の関数コードを含めました。
@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@SuppressLint("NewApi")
public void onStart()
{
super.onStart();
//determine if phone uses lock pattern
//It returns 1 if pattern lock enabled and 0 if pin/password password enabled
ContentResolver cr = getBaseContext().getContentResolver();
lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED, 0);//Settings.System
//returns 1 if pin/password protected. 0 if not
KeyguardManager keyguardManager = (KeyguardManager) getBaseContext().getSystemService(Context.KEYGUARD_SERVICE);
if( keyguardManager.isKeyguardSecure())
{
//it is pin or password protected
pinPasswordEnable=1;
}
else
{
//it is not pin or password protected
pinPasswordEnable=0;
}//http://stackoverflow.com/questions/6588969/device-password-in-android-is-existing-or-not/18716253#18716253
//determine if adb is enabled. works
adb=Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0);
//determine if bluetooth is enabled.works
bluetooth=Settings.Global.getInt(cr, Settings.Global.BLUETOOTH_ON, 0);
//Settings.System BLUETOOTH_DISCOVERABILITY
//determine if wifi is enabled. works
WifiManager wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
if (wifi.isWifiEnabled())
{
//wifi is enabled
wifiInt=1;
}
else
wifiInt=0;
//determine if data is encrypted
getDeviceEncryptionencryption();
//determine if gps enabled
}//end of onStart() function
この質問に答えるためにさらにコードを投稿する必要がある場合は、お知らせください。ご協力いただきありがとうございます。たぶん、問題は何かに関係していますsuper.onStart();
スプラッシュ ロード画面が問題の解決に役立つと思う人はいますか?