Я хочу, чтобы загрузить в службуIllegalArgumentException: Попытка выполнить удаленную операцию асинхронно без обработчика к теме слушателя
Я использую эту библиотеку кода для загрузки owncloud.org
public class MainActivity extends Activity implements OnRemoteOperationListener, OnDatatransferProgressListener {`
private Handler mHandler;
private OwnCloudClient mClient; `
private void startUpload() {
File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
File fileToUpload = ;
String remotePath =;
String mimeType =;
UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType);
uploadOperation.execute(mClient, this, mHandler);
}
I хочу загрузить в конце службы я пишу это:
общественный класс MyService extends Service реализует OnRemoteOperationListener { частный обработчик mHandler;
private OwnCloudClient mClient;
public MyService() {
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Let it continue running until it is stopped.
if (intent != null) {
final String action = intent.getAction();
if (ACTION.equals(action)) {
Uri serverUri = Uri.parse(server);
mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true);
mClient.setCredentials(
OwnCloudCredentialsFactory.newBasicCredentials(
username, pass
)
);
try {
actionSendList(dest);
} catch (IOException e) {
e.printStackTrace();
}
}
} return START_STICKY;}
private void actionSendList(String dest) throws IOException {
//String remotePath = FileUtils.PATH_SEPARATOR +"/nuovo/"+ files.gString mimeType = getString(R.string.sample_file_mimetype);
UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(files.get(i).getAbsolutePath(), remotePath , null);
//uploadOperation.addDatatransferProgressListener(context);
uploadOperation.execute(mClient,this,mHandler);
}
}
@Override
public void onRemoteOperationFinish (RemoteOperation caller, RemoteOperationResult result){
if (!result.isSuccess()) {
Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show();
Log.i("service", "fail");
}
}
} приложение аварии на uploadOperation.execute (mClient, это, mHandler);
Я не решил. я создал обработчик в сервисе android и позвонил uploadOperation.execute (mClient, this, mHandler); в команде запуска, но l'app crah –
Я забыл mHandler = new Handler(); –