I use an Indeterminate progress dialog when I publish, but I want to replace it with a progress bar, with upload percent, like what Facebook is doing.
I used android-simple-facebook library but I can use native Facebook SDK too, if it will do what I want.
This is my code:
public void publish(final Photo photo, OnPublishListener onPublishListener) {
this.onPublisherListener = onPublishListener;
isPublish = true;
if (!simpleFacebook.isLogin())
simpleFacebook.login(this);
else {
if (isPermissionAllowed("publish_actions")) {
isPublish = false;
if (photo != null)
simpleFacebook.publish(photo, false, onPublishListener);
} else {
requestUserPhotosPermissionAndPublish(photo, onPublishListener);
}
}
}
and my OnPublishListener
new OnPublishListener() {
@Override
public void onComplete(String response) {
super.onComplete(response);
}
@Override
public void onException(Throwable throwable) {
super.onException(throwable);
}
@Override
public void onFail(String reason) {
super.onFail(reason);
}
}
Also there was a solution here facebook upload progress, but it is not available on the current Facebook SDK version.
Well you are not using OnPublishListener object to effectively publish progress. You can simply refactor your code in this way: Create an interface:
Then refactor publish in this way:
Finally when you call publish method, you only need to implement publishProgress(int status) in the correct way:
I hope to help you.