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"
.
Here's the 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.
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.
Huawei Phones disable logcat, a small improvement on the above answer
Dial:
*#*#2846579#*#*
and a hidden menu is shown. Go to "Background Setting" -> "Log setting" and enable the log levels.
Specifically enable: AP Log, Charge Log and Sleep Log.
Source: https://www.xda-developers.com/huawei-phones-disable-logcat-heres-how-to-restore-access/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With