我正在尝试使用Robolectric测试Parse.com的推送通知.由于初始化必须在Application类中完成,我需要对其进行测试.到目前为止,该应用程序在模拟器上运行良好,但我无法使用Robolectric进行测试.
我的onCreate应用程序类:
public void onCreate() {
super.onCreate();
// Add your initialization code here
Parse.initialize(this, APP_KEY,
CLIENT_ID);
// Specify an Activity to handle all pushes by default.
PushService.setDefaultPushCallback(this, MainActivity.class);
// Save the current Installation to Parse.
//This is null on test
android_id = Secure.getString(getApplicationContext()
.getContentResolver(), Secure.ANDROID_ID);
System.out.println("android id >>" + android_id);
ParseInstallation installation = ParseInstallation
.getCurrentInstallation();
installation.put("UniqueId", android_id);
installation.saveInBackground();
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// If you would like all objects to be private by default, remove this
// line. …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码将SwitchCompat添加到“溢出”菜单:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_dummy_content"
android:title=""
android:actionViewClass="android.support.v7.widget.SwitchCompat"
app:showAsAction="never"
app:actionLayout="@layout/menu_item_switch"/>
<!-- TODO: Delete this after bug fix-->
<item
android:id="@+id/menu_dummy_content_2"
android:title="Second Title"
app:showAsAction="never"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
menu_item_switch的布局为:
<android.support.v7.widget.SwitchCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/menu_item_switch_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/menu_item_dummy_tasks"
android:layout_centerVertical="true"/>
Run Code Online (Sandbox Code Playgroud)
如果我执行app:showAsAction =“ ifRoom”或其他任何操作,则开关看起来可以正常运行,并且侦听器可以正常运行。但是,一旦我使showAsAction成为从来没有。开关视图变为白色/空,但onOptionsItemSelected表示单击的项目为menu_dummy_content。

我还尝试在自定义布局中仅使用TextView,它也为empty。我想念什么吗?
我为我的应用程序启用了本地数据存储.一切都很好,固定和取消固定.但是每当我在大约20秒内重新打开应用程序(不重新安装)时,我会在这里获得带有堆栈跟踪的 ANR .
运行时异常说enableOfflineStore() called multiple times.
但我找不到任何disableOfflineStore或disableLocalDataStore选项.
在线命令com.example.try_masterdetail.WebsiteListActivity.onCreate(WebsiteListActivity.java:60)是Parse.enableLocalDatastore(getApplicationContext());
在ANR对话框上单击"确定"并再次打开后,应用程序再次运行.
我不知道它是不是一个bug,或者我应该在onStop或Activity的生命周期中的某个地方调用一些东西.我试图搜索但找不到任何东西.请帮忙.
我有一个(当前)1567个对象的类.它们是我从网站的RSS源解析的文章的网址,标题和发布日期.云作业是周期性的,因此对象不断增加.虽然我检查了beforesave中的唯一性,但有时会出现一些重复的项目,大约10%的对象是重复的.
我一直在尝试删除这些重复项,并希望创建一个可以立即获取所有对象的查询逻辑.查询的最大限制是1000.我在Parse帮助中提到了这个问题,并尝试将其转换为JavaScript云代码.
Parse.Cloud.job("DeleteDuplicate", function(request, status) {
var query = new Parse.Query(NewsArticle);
var allObjectArray= [];
var limit = 1000;
var skip = 0;
var repeat = true;
query.limit(limit);
query.skip(skip);
do{
query.find({
success: function(results) {
allObjectArray.push(results.concat());
if(results.length === limit){
skip = skip+limit;
query.skip(skip);
repeat = true;
console.log("true");
}else{
repeat = false;
console.log("false");
}
console.log("Successfully retrieved " + results.length);
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
status.error("Error: " + error.code + " " …Run Code Online (Sandbox Code Playgroud)