我使用Android Studio创建了Android项目及其后端AppEngine端点对应项.我有一个数据存储区,我正在使用Objectify.系统工作得很好,直到我在查询中添加了一个过滤器(仅显示特定的给定电子邮件).
Query<Report> query = ofy().load().type(Report.class).filter("email", user.getEmail()).order("email").order("-when").limit(limit);
Run Code Online (Sandbox Code Playgroud)
这是POJO数据存储区实体:
@Entity
public class Report {
@Id
Long id;
String who;
@Index
Date when;
String what;
@Index
String email;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试测试时,我从Google API Explorer收到此类错误:
com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
<datastore-index kind=\"AccessReport\" ancestor=\"false\" source=\"manual\">
<property name=\"email\" direction=\"asc\"/>
<property name=\"when\" direction=\"desc\"/>
</datastore-index>
Run Code Online (Sandbox Code Playgroud)
据我所知,我只需要创建一个复合索引,包括特定字段的电子邮件和时间,以及它们的特定排序方向.
但是,我找到的大多数文档都告诉我编辑datastore-indexes.xml.
App Engine预定义实体的每个属性的简单索引.App Engine应用程序可以在名为datastore-indexes.xml的索引配置文件中定义更多自定义索引,该文件在应用程序的/ war/WEB-INF/appengine生成的目录中生成.
不幸的是,这个文件似乎并不存在于我的项目中.
是否有人熟悉使用Android Studio时改变这种情况的方法?
google-app-engine objectify google-cloud-endpoints google-cloud-datastore android-studio
我使用DocumentFile检查文件元数据和存在.这是如此实现的:
DocumentFile df = DocumentFile.fromSingleUri(context, uri);
boolean exists = df.exists();
Run Code Online (Sandbox Code Playgroud)
该文件的uri以前工作过,直到我有意在文件系统中手动删除该文件,以查看应用程序将如何反应.现在这个堆栈跟踪出现在App中:
03-14 11:33:08.559 27087-27097/? E/DatabaseUtils: Writing exception to parcel
java.lang.IllegalArgumentException: Failed to determine if primary:Download/thefile.txt is child of primary:Download: java.io.FileNotFoundException: Missing file for primary:Download/thefile.txt at /storage/emulated/0/Download/thefile.txt
at com.android.externalstorage.ExternalStorageProvider.isChildDocument(ExternalStorageProvider.java:326)
at android.provider.DocumentsProvider.enforceTree(DocumentsProvider.java:198)
at android.provider.DocumentsProvider.query(DocumentsProvider.java:489)
at android.content.ContentProvider.query(ContentProvider.java:1017)
at android.content.ContentProvider$Transport.query(ContentProvider.java:238)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
at android.os.Binder.execTransact(Binder.java:453)
03-14 11:33:08.561 27046-27419/packagename W/DocumentFile: Failed query: java.lang.IllegalArgumentException: Failed to determine if primary:Download/thefile.txt is child of primary:Download: java.io.FileNotFoundException: Missing file for primary:Download/thefile.txt at /storage/emulated/0/Download/thefile.txt
Run Code Online (Sandbox Code Playgroud)
它不会使App崩溃,它只是在我每次尝试使用DocumentFile时生成此堆栈跟踪.所以在最坏的情况下,这只是logcat的一个刺激因素.
我希望避免这种FileNotFoundException使用.exists() …
我的问题是:
我需要创建一个使用NinePatch创建的重新缩放的位图.
我当前的系统从NinePatch文件创建一个Bitmap.然后将其输入NinePatch(或NinePatchDrawable).然后我需要调整它并输出到另一个Bitmap.
我已审阅本,它帮了不少忙.
这是我目前的代码:
try {
Bitmap bitmap1 = BitmapFactory.decodeStream(getAssets().open("gfx/head.9.png"));
// Using NinePatch?
NinePatch patch = new NinePatch(bitmap1, bitmap1.getNinePatchChunk(), null);
// Or NinePatchDrawable?
NinePatchDrawable patch = new NinePatchDrawable(bitmap1, bitmap1.getNinePatchChunk(), new Rect(), null);
// Set dimensions from NinePatch and create new bitmap
// Bitmap bitmap2 = ?
}
catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud) 我的 C 代码无法找到我在 Java 中的公共静态函数调用。它设法找到了没有错误的类。
我正在尝试将结果返回给回调方法onResponse。“5”稍后会被更复杂的东西取代。
我在 StackOverflow 上似乎有类似的问题,但到目前为止似乎没有任何变化有帮助。也许我有逻辑错误?
我的 JNI(更新 #2):
void cec_debug_msg(JNIEnv *env, cec_rx_message_t* msg) {
jclass cls = (*env)->FindClass(env, "com/example/utils/CECUtils");
if(!cls) {
LOGE("Could not find the CEC class.");
} else {
jmethodID methodid = (*env)->GetStaticMethodID(env, cls, "onResponse", "(I)V");
if(!methodid) {
// Code always reaches this point, never finding the method
LOGE("Could not find the callback method.");
} else {
LOGV("Called static void method.");
(*env)->CallStaticVoidMethod(env, cls, methodid, 5);
}
}
}
Run Code Online (Sandbox Code Playgroud)
此代码包含在从此函数调用的方法中:
JNIEXPORT int JNICALL Java_com_example_utils_CECUtils_startListening(JNIEnv …Run Code Online (Sandbox Code Playgroud) 为什么我们\n在用JSON数据读取数据时添加BufferedReader?
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while((line = reader.readLine())!=null){
sb.append(line + "\n");
}
Run Code Online (Sandbox Code Playgroud) 该问题基于针对Android的Google应用内结算服务.特别是功能isBillingSupported.
int result = mBillingService.isBillingSupported(3, mOwner.getPackageName(), "inapp")
Run Code Online (Sandbox Code Playgroud)
首先,这个函数返回了什么?这些文档非常隐秘:
成功时RESULT_OK(0),故障时对应的结果代码
我发现的唯一代码似乎与支持计费的问题无关.所有看起来具体的,是0是成功的.有什么错误?
其次,该功能检查是否支持计费?我有一个完全能够进行应用程序内计费的手机,当我连接到合理的互联网资源(如WiFi)时,此功能确实返回"真实".但是,如果我的连接不稳定,它将不会返回"true".所以我假设它检查一个良好的连接.还有什么检查?
我有一个非常奇怪的错误,我无法弄清楚.
float distance = Utils.distance(this.spriteStartX, this.spriteStartY, this.getX(), this.getY());
Utils.log("D_Check: "+distance+" >= "+this.spriteDistance);
if(distance >= this.spriteDistance);
{
Utils.log(distance+" is greater than "+this.spriteDistance);
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我确定了我的精灵来源与其当前位置之间的距离.(为简单起见,这是8.034246f).this.spriteDistance是7000.0f.
在我收到的调试器中:
D_Check: 8.034246 >= 7000.0
8.034246 is greater than 7000.0
Run Code Online (Sandbox Code Playgroud)
显然这是非常错误的.我错过了一些非常简单的东西吗?
我正在尝试对应该显示通过ViewModel中的LiveData属性公开的数据的视图进行数据绑定,但是我没有找到将LiveData中的对象绑定到视图的方法。从XML中,我只能访问LiveData实例的value属性,而不能访问其中的对象。我错过了什么吗?
我的ViewModel:
class TaskViewModel @Inject
internal constructor(private val taskInteractor: taskInteractor)
: ViewModel(), TaskContract.ViewModel {
override val selected = MutableLiveData<Task>()
val task: LiveData<Task> = Transformations.switchMap(
selected
) { item ->
taskInteractor
.getTaskLiveData(item.task.UID)
}
... left out for breivety ...
}
Run Code Online (Sandbox Code Playgroud)
我试图将任务对象的值绑定到我的视图中,但是当尝试在我的视图中设置任务的值时,我只能这样做android:text="@={viewmodel.task.value}"。我无权访问任务对象的字段。在LiveData对象中提取对象值的诀窍是什么?
我的任务课:
@Entity(tableName = "tasks")
data class Task(val id: String,
val title: String,
val description: String?,
created: Date,
updated: Date,
assigned: String?)
Run Code Online (Sandbox Code Playgroud) android android-databinding android-livedata android-viewmodel