在我的应用程序"Tide Now WA"中,我最近使用新的Nexus 9平板电脑(Lollipop - API 21)测试了兼容性.
它会写一些按钮文字.此应用程序使用Android 2.3和Android 4.0正确编写文本.即混合资本和小写字母.
当我的Nexus 9上运行相同的应用程序时,文本中的所有字母都大写.
FWIW我的清单包含以下声明:
uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14"
我可以在我的代码中修复此问题,还是操作系统中的错误感谢
我正在重写我的Android
应用程序,以消除直接调用onResume()
.
我的应用程序目前在其中完成大部分工作onResume()
,然后发布显示,这就是结束onResume()
.
@Override
public void onResume() {
super.onResume();
// get current date and time,
// and determine if daylight savings time is in effect.
//...600 lines of code
// output both the chart and report
//
image.setImageBitmap(heightChart);
report.setImageBitmap(reportBitmap);
}
Run Code Online (Sandbox Code Playgroud)
下一步是收集用户输入,告诉我用户希望对报告进行哪些更改.(它可能是新位置,新日期或新显示样式等).这样做如下:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
final int STATION_REQUEST = 1;
int test = 1;
switch (item.getItemId()) {
case R.id.refresh: {
userDateSet = false;
onResume();
return true;
} // come to the …
Run Code Online (Sandbox Code Playgroud) 我读取手机的原始高度来调整显示输出的大小,并确定顶部和底部的遮挡区域。这是一个基于选项卡的应用程序。我的显示纯粹是编程性的,它仅根据屏幕尺寸以图形方式布局。iPhone 12 mini 的显示屏比应有的小。其他 iPhone 12 类型显示正常。
在 xcode 模拟器中的各种 iPhone 类型上测试我的新应用程序时,它们看起来是正确的。但当我将该应用程序安装到 iPhone 12 mini 上时,显示屏比应有的小。我了解到模拟器返回本机高度值 2436,但手机返回值 2340。 此代码检查显示并告诉我按手机类型在屏幕顶部和底部保留多少:
nativeHeight=UIScreen.main.nativeBounds.height
if nativeHeight==1136 || nativeHeight==1334 // SE,6S,7,8
{reserveTopPixels=40; reserveBottomPixels=98}
else if nativeHeight==1792 // 11, XR
{reserveTopPixels=88; reserveBottomPixels=198}
else if nativeHeight==2208 // 6s+ 7+ 8+
{reserveTopPixels=54; reserveBottomPixels=146}
else if nativeHeight==2436 || nativeHeight==2688 // X, XS, 11Pro, 11, Xr
{reserveTopPixels=132; reserveBottomPixels=260}
else if nativeHeight==2340 //iPhone 12 mini "downsampled screen"
{reserveTopPixels=132; reserveBottomPixels=260; nativeHeight = 2436}
else if nativeHeight==2532 // 12, 12 pro
{reserveTopPixels=132; …
Run Code Online (Sandbox Code Playgroud) 我的应用程序显示导航图,如果当前 GPS 位置可用,它也会显示。我在一艘沿着已知路线行驶的船上对此进行了测试。有时会显示正确的位置。有时我会得到旧的 GPS 位置,即使是在要求重新读取时也是如此。有时,它似乎会卡在旧位置进行多次读取。当这种情况发生时,我运行了谷歌地图,它似乎清除了错误,我又开始获取新的位置。
// try to look at GPS....
status1 = checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION);
if (status1 != PackageManager.PERMISSION_GRANTED)
{ requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},10);
}
status2 = checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION);
Object cancellationToken = null;
if (status2 == PackageManager.PERMISSION_GRANTED)
fusedLocationClient.getCurrentLocation(PRIORITY_HIGH_ACCURACY, (CancellationToken) cancellationToken)
.addOnSuccessListener(this, location -> // using lambda expression...
{ if (location != null)
{ GPSLatitude = location.getLatitude();
GPSLongitude = location.getLongitude();
gotGPS = true;
//if we have a location, and it is on chart, draw the blue dot....
Run Code Online (Sandbox Code Playgroud)
谷歌地图比我更擅长读取 GPS。我应该考虑另一种方法吗?