java mSecurityInputMethodService 在 logcat 中为 null
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38587844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mSecurityInputMethodService is null in logcat
提问by Fe Ri
I wrote a little androidapp 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 logthe longitude and latitude, but only logs "mSecurityInputMethodService is null"
.
我写了一个小android应用程序,它应该显示智能手机的当前位置(最后一个已知位置)。虽然我复制了示例代码,并尝试了其他几种解决方案,但似乎每次都出现相同的错误。我的应用程序由一个按钮组成。按下按钮应该记录经度和纬度,但只记录"mSecurityInputMethodService is null"
。
Here's the MainActivity.java:
这是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);
}
}
I also used <uses-permission>
in the Manifest file. I would really appreciate an explanation what does "mSecurityInputMethodService is null"
really means.
我也在<uses-permission>
Manifest 文件中使用过。我真的很感激解释"mSecurityInputMethodService is null"
真正意味着什么。
回答by Klatschen
For my Huawei device the following helps:
对于我的华为设备,以下帮助:
Dial:
拨号:
*#*#2846579#*#*
and a hidden menu is shown. Go to "Background Setting" -> "Log setting"and enable the log levels.
并显示隐藏菜单。转到“背景设置”->“日志设置”并启用日志级别。
回答by Ed Walpole
Huawei Phones disable logcat, a small improvement on the above answer
华为手机禁用logcat,对上面的回答做了一个小改进
Dial:
拨号:
*#*#2846579#*#*
*#*#2846579#*#*
and a hidden menu is shown. Go to "Background Setting"-> "Log setting"and enable the log levels.
并显示隐藏菜单。转到“背景设置”-> “日志设置”并启用日志级别。
Specifically enable: AP Log, Charge Logand Sleep Log.
具体启用:AP Log、Charge Log和Sleep Log。
Source: https://www.xda-developers.com/huawei-phones-disable-logcat-heres-how-to-restore-access/
来源:https: //www.xda-developers.com/huawei-phones-disable-logcat-heres-how-to-restore-access/
回答by Haseeb Hassan Asif
I had the same error while accessing keyboard and the keyboard was not showing. And turning on log didn't help. It turns out i was using google keyboard and i switched to huawei swype and it was solved.
我在访问键盘时遇到了同样的错误并且键盘没有显示。打开日志没有帮助。原来我使用的是谷歌键盘,我切换到华为 swype 并解决了。