我有以下一次性工作人员.
// Create a Constraints that defines when the task should run
Constraints constraints = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.UNMETERED)
.setRequiresBatteryNotLow(true)
// Many other constraints are available, see the
// Constraints.Builder reference
.build();
OneTimeWorkRequest oneTimeWorkRequest =
new OneTimeWorkRequest.Builder(SyncWorker.class)
.setConstraints(constraints)
.addTag(SyncWorker.TAG)
.build();
Run Code Online (Sandbox Code Playgroud)
根据https://developer.android.com/topic/libraries/architecture/workmanager
// (Returning RETRY tells WorkManager to try this task again
// later; FAILURE says not to try again.)
Run Code Online (Sandbox Code Playgroud)
我想知道,如果SyncWorker继续回来RETRY,重试策略是WorkManager什么?例如,最大重试次数是WorkManager多少?文档不清楚.
我可以知道拥有.hgtags的目的是什么?我可以删除它吗?因为它不在.hg文件夹中,并且似乎"污染"我的实际源代码目录.
我刚刚意识到谷歌将AdMob嵌入到最新的Google Play服务中(4+)
我想知道,如果我更喜欢https://developers.google.com/mobile-ads-sdk/docs/#play而不是https://developers.google.com/mobile-ads-sdk/docs/#android?因为我没有看到谷歌的官方立场.
我之所以这么说,我发现Google Play服务中的AdMob还是很麻烦的.
这是我的观察.
从我的角度来看,这似乎是一种不受欢迎的行为.这就是为什么,我仍然不愿意迁移新的Google Play服务.
可以在此处找到演示该错误的完整源代码:Google Play服务的AdMob将执行不需要的自动滚动
最近,我有Android代码访问Google云端硬盘.我正在使用Google API Client Library for Java而不是Google Play服务客户端库
private static GoogleCloudFile searchFromGoogleDrive(Drive drive, String qString, HandleUserRecoverableAuthIOExceptionable h, PublishProgressable p) {
try {
Files.List request = drive.files().list().setQ(qString);
do {
if (p.isCancelled()) {
return null;
}
FileList fileList = request.execute();
Run Code Online (Sandbox Code Playgroud)
如果我使用,代码可以在几年内完成100%罚款targetSdkVersion 21.
最近,我将我的应用迁移到targetSdkVersion 23了Google Drive相关代码的0更改.
但是,代码崩溃了FileList fileList = request.execute();,但有以下异常.
Process: org.yccheok.jstock.gui, PID: 30317
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at …Run Code Online (Sandbox Code Playgroud) 目前,我有以下对话框,我将对其项目执行展开/折叠动画.
该对话框通过以下代码创建
import android.support.v7.app.AlertDialog;
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final AlertDialog dialog = builder.setView(view).create();
final ViewTreeObserver vto = view.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
ViewTreeObserver obs = view.getViewTreeObserver();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
// http://stackoverflow.com/questions/19326142/why-listview-expand-collapse-animation-appears-much-slower-in-dialogfragment-tha
int width = dialog.getWindow().getDecorView().getWidth();
int height = dialog.getWindow().getDecorView().getHeight();
dialog.getWindow().setLayout(width, height);
}
});
Run Code Online (Sandbox Code Playgroud)
但是,当执行动画时,这是副作用.
请注意,动画后对话框中不需要的额外白色区域不是由我们的自定义视图引起的.它是对话框本身的系统窗口白色背景.
我倾向于使对话框的系统窗口背景变得透明.
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final AlertDialog dialog = builder.setView(view).create();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Run Code Online (Sandbox Code Playgroud)
虽然不再看到不需要的白色背景,但对话框的原始边距也消失了.(对话框宽度现在是全屏宽度)
如何在不影响保证金的情况下使其透明?
我们尝试sqlite_sequence使用以下代码进行更新.
WeNoteRoomDatabase weNoteRoomDatabase = WeNoteRoomDatabase.instance();
weNoteRoomDatabase.query(new SimpleSQLiteQuery("UPDATE sqlite_sequence SET seq = 0 WHERE name = 'attachment'"));
Run Code Online (Sandbox Code Playgroud)
但是,它完全没有效果.我sqlite_sequence使用SQLite浏览器检查表内容.计数器未重置为0.
如果我们尝试在同一个SQLite文件上使用SQLite浏览器手动运行相同的查询,它就可以正常工作.
我们的房间数据库非常简单.
@Database(
entities = {Attachment.class},
version = 6
)
public abstract class WeNoteRoomDatabase extends RoomDatabase {
private volatile static WeNoteRoomDatabase INSTANCE;
private static final String NAME = "wenote";
public abstract AttachmentDao attachmentDao();
public static WeNoteRoomDatabase instance() {
if (INSTANCE == null) {
synchronized (WeNoteRoomDatabase.class) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(
WeNoteApplication.instance(),
WeNoteRoomDatabase.class,
NAME
)
.build(); …Run Code Online (Sandbox Code Playgroud) 目前,我需要使用paddingTop和paddingBottom的RecyclerView,因为我想避免复杂的空间计算,在我的第一RecyclerView项和最后一项。
但是,我注意到requiresFadingEdge效果也会受到影响。
这是我的XML
<androidx.recyclerview.widget.RecyclerView
android:requiresFadingEdge="vertical"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:overScrollMode="always"
android:background="?attr/recyclerViewBackground"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false" />
Run Code Online (Sandbox Code Playgroud)
如您所见,淡入淡出效果下降了40dp,这不是我想要的。
褪色效果看起来不错。但是,我需要有非零paddingTop和paddingBottom,为我RecyclerView。
有没有一种方法,使RecyclerView的requiresFadingEdge通过影响paddingTop和paddingBottom?
当我阅读Programming Perl,第2版,第51页时,有些东西让我困惑:
sub newopen {
my $path = shift;
local *FH; #not my!
open (FH, $path) || return undef;
return *FH;
}
$fh = newopen('/etc/passwd');
Run Code Online (Sandbox Code Playgroud)
我知道,为什么我们不会重新开始使用我的?到目前为止,如果我们使用my(),我看不出任何问题.
谢谢!
目前,我想知道我的应用程序中正在加载哪个属性文件.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package example0;
import java.util.Locale;
/**
*
* @author yccheok
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Locale.setDefault(Locale.SIMPLIFIED_CHINESE); // Bundle_zh_CH.properties will be loaded.
//Locale.setDefault(Locale.CHINA); // Bundle_zh_CH.properties will be loaded.
//Locale.setDefault(Locale.TRADITIONAL_CHINESE); // Bundle.properties will be loaded.
//Locale.setDefault(Locale.CHINESE); // Bundle.properties will be loaded.
String Hello = java.util.ResourceBundle.getBundle("example0/Bundle").getString("HELLO");
System.out.println(Hello);
System.out.println("Locale.SIMPLIFIED_CHINESE's language …Run Code Online (Sandbox Code Playgroud) 我有以下Java SE代码,它在PC上运行
public static void main(String[] args) {
// stringCommaPattern will change
// ","abc,def","
// to
// ","abcdef","
Pattern stringCommaPattern = Pattern.compile("(\",\")|,(?=[^\"[,]]*\",\")");
String data = "\"SAN\",\"Banco Santander, \",\"NYSE\"";
System.out.println(data);
final String result = stringCommaPattern.matcher(data).replaceAll("$1");
System.out.println(result);
}
Run Code Online (Sandbox Code Playgroud)
我得到了预期的结果
"SAN","Banco Santander, ","NYSE"
"SAN","Banco Santander ","NYSE"
Run Code Online (Sandbox Code Playgroud)
但是,来到Android时.
Pattern stringCommaPattern = Pattern.compile("(\",\")|,(?=[^\"[,]]*\",\")");
String data = "\"SAN\",\"Banco Santander, \",\"NYSE\"";
Log.i("CHEOK", data);
final String result = stringCommaPattern.matcher(data).replaceAll("$1");
Log.i("CHEOK", result);
Run Code Online (Sandbox Code Playgroud)
我越来越
"SAN","Banco Santander, ","NYSE"
"SAN","Banco Santandernull ","NYSE"
Run Code Online (Sandbox Code Playgroud)
任何建议和解决方法,我如何使这些代码的行为与Java SE相同?
其他模式也产生相同的结果.看来,Android正在为无法匹配的组使用空字符串,而Java SE正在使用空字符串作为不匹配的组. …
android ×7
java ×2
admob ×1
android-architecture-components ×1
android-room ×1
filehandle ×1
lexical ×1
mercurial ×1
perl ×1