Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 未从requestSync调用SyncAdapter_Android_Android Syncadapter - Fatal编程技术网

Android 未从requestSync调用SyncAdapter

Android 未从requestSync调用SyncAdapter,android,android-syncadapter,Android,Android Syncadapter,我有一个自定义帐户,SyncAdapter和相应的服务等设置,并在模拟器(Nexus 5X API 25)上运行良好。我目前正试图手动调用onPerformSync进行测试和理解,因此我使用以下代码- Account acct = getMyAccount() ; Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC

我有一个自定义帐户,SyncAdapter和相应的服务等设置,并在模拟器(Nexus 5X API 25)上运行良好。我目前正试图手动调用onPerformSync进行测试和理解,因此我使用以下代码-

                Account acct  = getMyAccount() ;
                Bundle bundle = new Bundle();
                bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
                if(permissionsHelper.canDoCalendar()){
                    ContentResolver.requestSync(acct, "com.android.calendar", bundle);
                }else{
                    Log.e(LOG_TAG, "Permissions not yet granted..Wont start syncadatper") ;
                }
这段代码可以在模拟器上运行,但不能在我的真实手机上运行。ContentResolver.requestSync会被调用,但在此之后,不会发生任何事情。我可以在emulator上使用调试器,但在requestSync之后,物理设备上的调试器不起作用,也看不到任何错误或堆栈跟踪-我一直在查看没有任何筛选器的日志,以确保在其他进程发出日志时不会遗漏日志(尽管emulator不会在其他进程中运行adatper). 我没有在adatper服务配置中提供android:process选项

使用targetSDK 25

服务配置:

    <service
        android:name=".core.calendar.SyncAdapterService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.content.SyncAdapter" />
        </intent-filter>

        <meta-data
            android:name="android.content.SyncAdapter"
            android:resource="@xml/calendar_syncadapter" />
    </service>

同步适配器配置

<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="com.android.calendar"
android:accountType="xxxxxx" <-- removed for the time from post
android:userVisible="true"
android:allowParallelSyncs="false"
android:isAlwaysSyncable="true"
android:supportsUploading="false"
/>

尝试添加此设置:

bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);

尝试添加此设置:

bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);