mSecurityInputMethodService 在 logcat 中为 null
我写了一个小的Android应用程序,应该显示智能手机的当前位置(最后一个已知位置)。尽管我复制了示例代码,并尝试了其他几种解决方案,但它似乎每次都有相同的错误。我的应用由一个按钮组成。按下按钮应记录经度和纬度,但仅记录 。"mSecurityInputMethodService is null"
以下是主要活动.java:
public class MainActivity extends Activity {
int response;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onbutclick();
}
});
}
public void onbutclick(){
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){
Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(loc != null){
Log.d("Latitude",Double.toString(loc.getLatitude()));
Log.d("Longitude",Double.toString(loc.getLongitude()));
}
}else{
ActivityCompat.requestPermissions(this,new String[] {Manifest.permission.ACCESS_FINE_LOCATION},response);
Intent inte = getIntent();
finish();
startActivity(inte);
}
}
我还在清单文件中使用。我真的很感激解释一下这到底意味着什么。<uses-permission>
"mSecurityInputMethodService is null"