android常见错误
2012-11-20 15:10:51 来源:WEB开发网添加android_sdk_home系统变量,其值为想要保存avd的目录,例如我放在D:\Program Files\android\avd下。
24、Activity has leaked window that was originally added
原因1:重写onKeyDown时,return super. onKeyDown(int keyCode, KeyEvent event)没有修改;
原因2:关闭Activity时,没有关闭AlertDialog造成的。
法一:将return super. onKeyDown(int keyCode, KeyEvent event)改为return false;
法二:@Override
protected void onPause()
{
super.onPause();
//关闭对话框
AlertDialog.dismiss();
}
法三:AndroidManifest.xml中,在相应的<Activity>节点中添加
android:configChanges="orientation|keyboardHidden|navigation"
25、unable to instantiate application
解决方法1:在AndroidManifest.xml中的application里的android:name要去掉;
解决方法2:全局类或者变量私有;
解决方法3:package路径错误。
26、IllegalArgumentException 'Provider "gps" unknown"
locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);触发不了LocationManager
加入以下一段参数就好了:
mLocationManager.addTestProvider(LocationManager.GPS_PROVIDER,
"requiresNetwork" == "", "requiresSatellite" == "", "requiresCell" == "", "hasMonetaryCost" == "",
"supportsAltitude" == "", "supportsSpeed" == "",
"supportsBearing" == "", android.location.Criteria.POWER_LOW,
android.location.Criteria.ACCURACY_FINE);
更多精彩
赞助商链接