草庐IT

re-doing-it-wrong

全部标签

android - 尝试捕捉 : Is it OK to leave applications with handled exceptions?

我对编程还很陌生,所以有些东西我是通过观察学到的,但还没有完全理解。Try-Catch就是其中之一。根据我的研究,try语句允许我定义一个代码块来测试错误,而catch语句允许我定义一个代码块,如果tryblock中发生错误则执行。我明白了。我曾尝试在收到导致应用程序崩溃的异常错误的情况下使用Try-Catch。Try-Catch似乎可以防止(停止)崩溃。但这是我的问题,有一个不断捕获异常错误的应用程序可以吗?例如,我正在使用EditText小部件。我希望EditText的输入值代表货币,所以我应用了android:inputType="numberDecimal"。我从中了解到的问题

java - 如何解决lint warning "field is never used"but it is serialized

我的Android项目中有一个包含一些变量的小类,我在构造函数中分配它们。然后我使用Gson库和函数将对象序列化为jsonStringGson::toJson(Objectsrc)如何解决这个lint警告:这些变量上的“privatefieldisassignedbutneveraccessed”?那个案例有特殊的评论吗?编辑:抱歉,还有另一个警告“字段可以转换为局部变量”,这是错误的!谢谢! 最佳答案 您可以在字段上添加@SuppressWarnings("unused")注释,以防止生成此类消息。

android - 共享首选项 : Is it a class or an interface?

我很困惑,请帮帮我。Androiddevelopersdocumentation说SharedPreferences是一个Interface我们也可以在grepCode上看到SharedPreferences是一个接口(interface)。但是developers.android还说SharedPreferences是一个Class.他们写。"TheSharedPreferencesclassprovidesageneralframework..."那么,SharedPreferences是一个类还是一个接口(interface)? 最佳答案

android - Xamarin 表格 : Is it possible to add disclosure indicator in Android?

我有一个TextCell,它在我的XamarinForms应用的iOS端添加了一个披露指示器:我也想为android端做同样的事情,但我似乎找不到任何自定义渲染器来做这样的事情。有没有人能做到这一点?如果有人能指出我的方向,我将不胜感激。 最佳答案 根据designguidelines,建议不要在Android的订单项上使用右指插入符(披露指示符)。Don'tuseright-pointingcaretsonlineitemsAcommonpatternonotherplatformsisthedisplayofright-poin

安卓奥利奥 : what should I do to publish my app as an Autofill service provider?

我是密码管理器应用的独立开发者。我应该怎么做,或者我应该实现什么(接口(interface)/API/服务),使我的应用程序成为自动填充服务提供商(在AndroidOreoAPI>=26的设备中)?我看了各种相关的文档,但是就是看不懂怎么弄。我错过了什么吗?目前我看到只有知名的密码管理器支持这个功能:欢迎任何提示。 最佳答案 像往常一样,谷歌自己的examplesrepositoryprovidesagoodstartingpoint用于学习AutofillFramework的API,并且涵盖的Material比我能放入答案的Mat

安卓 : Do something when battery is at a defined level

我在这里遇到了一个小问题。我希望我的应用程序执行某些操作,但仅限于电池电量为10%时。我的应用不会持续监控电池电量;它只是等待LOW_BATTERYIntent。如果我不指定级别它会起作用,但它会起作用3次:15%、10%和5%我只希望它以10%的速度做某事。这是我的代码:publicvoidonReceive(Contextcontext,Intentintent){if(intent.getAction().equals(ACTION_BATTERY_LOW)){intlevel=intent.getIntExtra(BatteryManager.EXTRA_LEVEL,-1);i

java - Xamarin 升级导致 "class file has wrong version 52.0, should be 50.0"错误

我在VisualStudio2015中升级到最新版本的Xamarin。然后我编译了我的Android项目并遇到了这个错误:cannotaccessandroid.app.Activitybadclassfile:[DRIVE]:[android-sdk-folder]\platforms\android-24\android.jar(android/app/Activity.class)classfilehaswrongversion52.0,shouldbe50.0Pleaseremoveormakesureitappearsinthecorrectsubdirectoryofthe

Java/安卓/ Kotlin : Reflection on private Field and call public methods on it

是否可以使用反射来访问对象的私有(private)字段并在该字段上调用公共(public)方法?一个classHello{privateWorldword}classWorld{publicBlaBlaBlafoo()}Helloh=newHello()Worldworld=reflectontheh//Andthenworld.foo() 最佳答案 可以使用反射使私有(private)字段可访问。以下示例(均用Kotlin编写)展示了它...使用Java反射:valhello=Hello()valf=hello::class.ja

android - 编辑文本框的计时器 : Only the original thread that created a view hierarchy can touch its views

如果输入错误的密码,我正在尝试使编辑文本框振动并立即更改颜色finalDrawableoldBackground=findViewById(R.id.email).getBackground();TimerTasktimerTask=newTimerTask(){@Overridepublicvoidrun(){MainActivty.this.findViewById(R.id.password).setBackground(oldBackground);MainActivty.this.findViewById(R.id.email).setBackground(oldBackgr

android - Cordova geolocation watchPosition frequency is higher the options allow it

在我的ionic/angularjs应用程序中,我使用了地理定位插件:https://github.com/apache/cordova-plugin-geolocation就像在我使用它来配置watch的文档中一样:varwatchOptions={frequency:10*1000,timeout:60*60*1000,enableHighAccuracy:true//maycauseerrorsiftrue};watch=navigator.geolocation.watchPosition(on_success,on_error,watchOptions);但是在android