我对 Android 应用程序开发有点陌生。在此代码中,我试图查看用户登录手机时是否启用了锁定模式。我在这里收到错误“int lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED);
,并且在 secure 字样下出现红色错误行
这是因为我必须删除安全类吗?任何帮助将不胜感激。
package com.example.phonesecurityassessment;
import android.content.ContentResolver;
import android.media.audiofx.BassBoost.Settings;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ContentResolver cr = getContentResolver();
int lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED);
if (lockPatternEnable==1)
{
//lock pattern enabled
}
if (lockPatternEnable==0)
{
//lock pattern disabled
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
最佳答案
I'm getting red, error lines under the words secure is this because I have to delcare the secure class?
不,您收到错误行是因为 Settings
的 import
错误。您需要 android.provider.Settings
,而不是 android.media.audiofx.BassBoost.Settings
。
关于java - 安全类 : Passlock enabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29929058/