- Intent upload_intent = new Intent(context, InstantUploadService.class);
- upload_intent.putExtra(InstantUploadService.KEY_ACCOUNT, account);
- upload_intent.putExtra(InstantUploadService.KEY_FILE_PATH, file_path);
- upload_intent.putExtra(InstantUploadService.KEY_DISPLAY_NAME, file_name);
- upload_intent.putExtra(InstantUploadService.KEY_FILE_SIZE, file_size);
- upload_intent.putExtra(InstantUploadService.KEY_MIME_TYPE, mime_type);
-
- context.startService(upload_intent);
+ // register for upload finishe message
+ // there is a litte problem with android API, we can register for particular
+ // intent in registerReceiver but we cannot unregister from precise intent
+ // we can unregister from entire listenings but thats suck a bit.
+ // On the other hand this might be only for dynamicly registered
+ // broadcast receivers, needs investigation.
+ IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
+ context.registerReceiver(this, filter);
+
+ Intent i = new Intent(context, FileUploader.class);
+ i.putExtra(FileUploader.KEY_ACCOUNT, account);
+ i.putExtra(FileUploader.KEY_LOCAL_FILE, file_path);
+ i.putExtra(FileUploader.KEY_REMOTE_FILE, INSTANT_UPLOAD_DIR + "/" + file_name);
+ i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
+ i.putExtra(FileUploader.KEY_MIME_TYPE, mime_type);
+ i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true);
+ context.startService(i);
+