2016-05-10 3 views
1

私はAndroid Developersのウェブサイトに記載されているガイドラインを使用して同期アダプタを実装しましたが、コードを実行するとエラーが発生します。スタックトレースは次のようになります。Android Sync Adapter - エラーの未破棄バンドルエラー

FATAL EXCEPTION: main 
java.lang.IllegalArgumentException: error unparceling Bundle at 
android.content.ContentResolver.validateSyncExtrasBundle(ContentResolver.java:1159) at 
android.content.ContentResolver.requestSync(ContentResolver.java:1120) 

私はマーシュマローをターゲットにしており、最小SDKは15です。アイデア?

答えて

1

あなたSyncRequestオブジェクトにbuild()を呼び出す前に、それはこのようになりますように、.setExtras(new Bundle())を置く:

SyncRequest request = new SyncRequest.Builder() 
       .syncPeriodic(syncInterval, flexTime) 
       .setSyncAdapter(account, authority) 
       .setExtras(new Bundle()) 
       .build(); 

私のための固定エラーを得たこと。あなたのために働くことを願っています。

0

これはおそらくBundleに入れたデータの種類に関係しています。 ContentResolver#requestSyncメソッドのjavadocに注意してください。すべてのタイプがサポートされているわけではありません。

/** 
* Start an asynchronous sync operation. If you want to monitor the progress 
* of the sync you may register a SyncObserver. Only values of the following 
* types may be used in the extras bundle: 
* <ul> 
* <li>Integer</li> 
* <li>Long</li> 
* <li>Boolean</li> 
* <li>Float</li> 
* <li>Double</li> 
* <li>String</li> 
* <li>Account</li> 
* <li>null</li> 
* </ul> 
* 
* @param account which account should be synced 
* @param authority which authority should be synced 
* @param extras any extras to pass to the SyncAdapter. 
*/ 
public static void requestSync(Account account, String authority, Bundle extras) { 
    requestSyncAsUser(account, authority, UserHandle.myUserId(), extras); 
} 
関連する問題