By simply setting a TextViews text to a string defined in code (that never can be null) I sometimes get an ArrayIndexOutOfBoundsException, this only happens in my live app, I never had this issue on any test device yet... And it seems to happen sometimes only, the user tells me it happens once and the next time everything works again. Any ideas what could be the cause here? For me, it looks like this crash should never ever …
我该怎么做呢?
我有一个秒表,我正在保存它的状态onSaveInstance并恢复它的状态onRestoreInstance......
现在我有以下问题:如果我停止线程onSaveInstance并且屏幕被锁定或关闭,onRestoreInstance则不会被调用并且秒表不会继续...
如果我不停止它,则秒表在后台运行并且即使屏幕关闭或活动不再活动...
那么处理这种事情的常用方法是什么?
PS:
我甚至有一个工作解决方案,一个局部变量来保存onStop事件中的运行状态并在事件中重新启动线程onStart......但我仍然想知道是否有一个使用android系统本身的"默认"解决方案.. ..
我使用显示条目列表的 RecyclerView。每个条目托管另一个 RecyclerView,它是一个图像列表。
我现在想让这个嵌套的 RecyclerView 可点击,不是它的项目,而是整个视图。
我怎样才能做到这一点?
问题:
这是包装适配器的视图:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="0dp"
android:layout_margin="5dp"
android:foreground="?android:attr/selectableItemBackground" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/rlTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Datum"
android:textStyle="bold"
android:id="@+id/tvDate" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Info"
android:id="@+id/tvInfo" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvData"
android:clickable="false"
android:focusableInTouchMode="false"
android:focusable="false"
android:layout_below="@+id/rlTop"
android:layout_width="match_parent"
android:layout_height="68dp"
android:scrollbars="horizontal" />
</RelativeLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud) 我想将文件从内部存储复制或移动到 SD 卡。我通过存储访问框架 (SAF) 和DocumentFile类来做到这一点...
复制是基于流的,DocumentFile并且没有像File设置上次修改日期的类的功能。
我知道,我将文件移动/复制到 SD 卡,所以我知道我创建了一个本地文件。有了这些信息,是否有可能以某种方式更新基础文件的最后修改日期DocumentFile?
似乎您无法在不丢失上次修改日期的情况下将文件从内部存储移动/复制到 SD 卡...
阅读 - 工作
public long lastModified(DocumentFile file, Context context)
{
long lastModified = 0;
final Cursor cursor = context.getContentResolver().query(file.getUri(), null, null, null, null);
try
{
if (cursor.moveToFirst())
lastModified = cursor.getLong(cursor.getColumnIndexOrThrow(DocumentsContract.Document.COLUMN_LAST_MODIFIED));
}
finally
{
cursor.close();
}
return lastModified;
}
Run Code Online (Sandbox Code Playgroud)
写作 - 不工作
public boolean setLastModified(DocumentFile file, Context context, long time)
{
ContentValues updateValues = new ContentValues();
updateValues.put(DocumentsContract.Document.COLUMN_LAST_MODIFIED, time);
int updated = …Run Code Online (Sandbox Code Playgroud) 是否可以TextView通过共享的元素过渡为a动画,并在进行动画时另外从颜色过渡?
我正在从活动中的文本过渡到工具栏的文本,因此想在过渡时切换颜色...
android transition android-transitions shared-element-transition
我正在使用播放服务v9.8.0(没有位置服务权限),当我MapView在对话框片段中使用时,我仍然面临泄漏.我在我的代码示例中使用它,我用它来显示一个位置而我没有setMyLocationEnabled(因为我甚至没有这个设置的权限).
有没有人在我的代码中看到问题?我得到的漏洞就像这里的那样:MapView v2保持了Context.我这样做:
MapView(因为我也允许使用静态地图,所以我的默认视图ImageView在我的布局中,将替换为a MapView)然后发生我的碎片泄漏MapView.mContext......
代码 - 对话片段
public class DialogMediaDetails extends DialogFragment
{
private GoogleMap mGoogleMap = null;
private MapView mMapView = null;
@Override
public final Dialog onCreateDialog(Bundle savedInstanceState)
{
Dialog dlg = ...; // create dialog
View view = ...; // get view from dialog
Location location = ...; // defined location
initGoogleMap();
return dlg;
}
private void initGoogleMap(Location location)
{ …Run Code Online (Sandbox Code Playgroud) 一旦我想要显示一个小部件并开始收听,我就会得到以下异常:
// the relevant stack trace, the rest is comming from my code
// before the code line I posted below
java.lang.RuntimeException: system server dead?
at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:189)
at com.my.app.utils.WidgetUtil.a(SourceFile:231)
...
android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.startListening(IAppWidgetService.java:481)
at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:185)
at com.my.app.utils.WidgetUtil.a(SourceFile:231)
...
Run Code Online (Sandbox Code Playgroud)
我的代码中的源代码如下:
mAppWidgetManager = AppWidgetManager.getInstance(context);
mAppWidgetHost = new AppWidgetHost(context, R.string.app_name);
mAppWidgetHost.startListening(); // <= this line leads to the crash
Run Code Online (Sandbox Code Playgroud)
意见
有谁知道可能导致这种情况的原因是什么?这是我可以在我的应用程序中解决的问题吗?用户说小部件在他的发射器中正常工作......
将我的整个项目迁移到android x后,我再也无法进行编译了.
我得到以下100个错误:
e: M:\tmp\EverywhereLauncher\app\generated\data_binding_base_class_source_out\devWithoutTestWithAccessibilityDebug\dataBindingGenBaseClassesDevWithoutTestWithAccessibilityDebug\out\com\my\app\databinding\ActivityMainBinding.java:52: error: cannot find symbol
@Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) {
^
symbol: class DataBindingComponent
location: class ActivityMainBinding
Run Code Online (Sandbox Code Playgroud)
我不知道从哪里继续.
我现在有两个问题.
我尝试了什么:
我在我的项目中跟随build.gradle将打印错误的数量增加到10000:
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "10000"
}
}
Run Code Online (Sandbox Code Playgroud)
这总是有效,但在这种情况下,它不会增加打印的错误
我接下来可以做些什么?
额外
我使用以下
android.enableJetifier=true
android.useAndroidX=true
Run Code Online (Sandbox Code Playgroud)我使用android studio 3.2,使用kotlin 1.2.61和3.3.0-alpha01gradle构建工具
3.3.0-alpha01gradle构建工具,因为我也使用了evernote com.evernote:android-state,否则没有 - 问题在这里解释:https://github.com/evernote/android-state/issues/56我使用以下方法来获取屏幕大小:
public static Point getScreenSize(Context context)
{
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int w = wm.getDefaultDisplay().getWidth();
int h = wm.getDefaultDisplay().getHeight();
return new Point(w, h);
}
Run Code Online (Sandbox Code Playgroud)
在我的三星Galaxy s6上,此方法返回1080x1920 ...虽然我的设备的分辨率为1440x2560.
为什么?有没有更好的方法来获得适用于较新手机的屏幕分辨率?
编辑
我在服务中需要这种方法!我没有帮助的视图/活动,只有应用程序上下文!我需要REAL像素
获得以下行为的前提条件是:
到目前为止我所知道的:
我尝试了什么:
/system/app=>这使得它可以卸载但它仍然是可以停用的/system/app-priv=>>与安装它相比没有任何改变/system/app/system/app-priv/<app_name>=>这会破坏应用程序思路
/system/app-priv/<app_name>?只是一个猜测,但我想在阅读其他内容时我已经读过这样的东西......如果这是真的,我如何将我的应用程序作为系统应用程序签名?我对替代解决方案持开放态度,我想要的是我的应用程序无法卸载也无法禁用
android ×10
androidx ×1
documentfile ×1
google-maps ×1
kotlin ×1
memory-leaks ×1
resolution ×1
restore ×1
save ×1
signature ×1
state ×1
system ×1
transition ×1
widget ×1