mSecurityInputMethodService is null in logcat(mSecurityInputMethodService 在 logcat 中为空)
问题描述
我编写了一个小 android 应用程序,它应该显示智能手机的当前位置(最后已知位置).虽然我复制了示例代码,并尝试了其他几种解决方案,但似乎每次都有相同的错误.我的应用程序由一个按钮组成.按下按钮应该记录经度和纬度,但只记录mSecurityInputMethodService is null"
.
I wrote a little android app that should display the current location (last known location) of the smartphone. Although I copied the example code, and tried several other solutions, It seems to have the same error every time. My app consists of a button. Pressing the button should log the longitude and latitude, but only logs "mSecurityInputMethodService is null"
.
这是 MainActivity.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);
}
}
我还在 Manifest 文件中使用了 <uses-permission>
.我真的很感激解释 "mSecurityInputMethodService is null"
的真正含义.
I also used <uses-permission>
in the Manifest file. I would really appreciate an explanation what does "mSecurityInputMethodService is null"
really means.
推荐答案
对于我的华为设备,以下帮助:
For my Huawei device the following helps:
拨号:
*#*#2846579#*#*
并显示一个隐藏菜单.转到后台设置"->日志设置"并启用日志级别.
and a hidden menu is shown. Go to "Background Setting" -> "Log setting" and enable the log levels.
这篇关于mSecurityInputMethodService 在 logcat 中为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mSecurityInputMethodService 在 logcat 中为空
基础教程推荐
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01