2013-08-02 2 views
0

문제가 있습니다. 그렇지 않으면 여기에 없을 것입니다.Google 백업 서비스가 작동하지 않습니다.

백업 서비스를 만들고 있지만 지금까지 전혀 작동하지 않습니다. Dunno는 어떤 문제인지 모르지만 테스트 (에뮬레이터 또는 전화를 통해 설명 됨)를하면 데이터가 복원되지 않습니다. 어쩌면 누군가가 도울 수 있습니까?

답변

0

그것은 오래된 질문하지만, 어쩌면 당신을 ...

<application 
    android:backupAgent="ee.elven.katja.AppsBackupAgent" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 

:

SharedPreferences UIDpref = getSharedPreferences("uidpref", 0); 
    Log.e("CODE", preferences.getBoolean("IDgenerated", false)+""); 
    BackupManager mBackupManager = new BackupManager(getApplicationContext()); 

    if(!preferences.getBoolean("IDgenerated", false)){ 
     SharedPreferences.Editor UIDedit = UIDpref.edit(); 
     String rnd = GenerateUID(30); 
     UIDedit.putString("UID", rnd); 
     UIDedit.putBoolean("IDgenerated", true); 
     UIDedit.commit(); 
     mBackupManager.dataChanged(); 
    } 

그리고 매니페스트 :

MyAppsBackupAgent

public class AppsBackupAgent extends BackupAgentHelper { 

// The name of the SharedPreferences file 
static final String PREFS = "uidpref"; 

// A key to uniquely identify the set of backup data 
static final String PREFS_BACKUP_KEY = "uidpref"; 

// Allocate a helper and add it to the backup agent 
@Override 
public void onCreate() { 
    SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS); 
    addHelper(PREFS_BACKUP_KEY, helper); 
} 

@Override 
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, 
     ParcelFileDescriptor newState) throws IOException { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onRestore(BackupDataInput data, int appVersionCode, 
     ParcelFileDescriptor newState) throws IOException { 
    // TODO Auto-generated method stub 

} 

보관은 mainactivity에서 발생 여전히 답이 필요합니다. AppsBackupAgent 구현에서 onRestore()onBackup() 개의 메소드를 삭제합니다.

Inherited BackupAgentHelper 구현은 등록 된 도우미에 복원/백업 이벤트를 전달하기 위해 디스패처를 사용합니다. 귀하의 구현은 단순히이 작업을 비활성화합니다.

관련 문제