我写了一点
安卓
应显示智能手机当前位置(上次已知位置)的应用程序。尽管我复制了示例代码,并尝试了其他几种解决方案,但似乎每次都有相同的错误。我的应用程序由一个按钮组成。按下按钮应该
日志
经度和纬度,但仅限日志
..。
下面是
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文件中使用了。我真的很感激你能给我解释一下
真正的意思是。
发布于 2016-08-23 14:57:42
对于我的华为设备,以下内容会有所帮助:
拨号:
*#*#2846579#*#*并显示隐藏菜单。转到
后台设置“->”日志设置
并启用日志级别。
发布于 2018-12-20 23:12:40
华为手机关闭logcat,这是对上述答案的一个小改进
拨号:
*
#
*
#2846579#
*
#
*
并显示隐藏菜单。转到
“背景设置”
->
“日志设置”
并启用日志级别。
具体启用:
AP日志
充电日志
和
睡眠日志
..。
来源:
https://www.xda-developers.com/huawei-phones-disable-logcat-heres-how-to-restore-access/
发布于 2019-12-19 18:42:25
访问键盘时出现相同的错误,键盘未显示。打开日志也没什么帮助。原来我用的是谷歌键盘,我换成了华为swype,问题就解决了。
https://stackoverflow.com/questions/38587844
复制相似问题