有人对this website了解了吗?
我正在尝试此处提供的代码,状态上传看起来不错,但我无法上传任何图片,好像UploadImageAsyn()
无法正常工作。这是我的代码
public class ShareButtonActivity extends Activity {
// SocialAuth Component
SocialAuthAdapter adapter;
Bitmap bitmap;
// Android Components
Button update;
EditText edit;
ImageView img;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
img =(ImageView) findViewById(R.id.imageView1);
img.buildDrawingCache();
bitmap = img.getDrawingCache();
// Create Your Own Share Button
Button share = (Button) findViewById(R.id.sharebutton);
share.setText("Share");
// Add it to Library
adapter = new SocialAuthAdapter(new ResponseListener());
// Add providers
adapter.addProvider(Provider.FACEBOOK, R.drawable.facebook);
// Enable Provider
adapter.enable(share);
}
/**
* Listens Response from Library
*
*/
private final class ResponseListener implements DialogListener {
@Override
public void onComplete(Bundle values) {
// Get name of provider after authentication
final String providerName=values.getString(SocialAuthAdapter.PROVIDER);
Log.d("ShareButton", "Provider Name = " + providerName);
Toast.makeText(ShareButtonActivity.this, providerName + " connected", Toast.LENGTH_LONG).show();
update = (Button) findViewById(R.id.update);
update.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
adapter.uploadImageAsync("Landscape Images", "icon.png", bitmap, 0,new UploadImageListener());
Toast.makeText(getApplicationContext(),"yoohooo ",Toast.LENGTH_SHORT).show();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(getApplicationContext(), "no", Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public void onError(SocialAuthError error) {
Log.d("ShareButton", "Authentication Error: " + error.getMessage());
}
@Override
public void onCancel() {
Log.d("ShareButton", "Authentication Cancelled");
}
@Override
public void onBack() {
Log.d("Share-Button", "Dialog Closed by pressing Back Key");
}
}
// To get status of message after authentication
private final class UploadImageListener implements SocialAuthListener<Integer> {
@Override
public void onExecute(String provider, Integer t) {
Log.d("Custom-UI", "Uploading Data");
Integer status = t;
Log.d("Custom-UI", String.valueOf(status));
Toast.makeText(getApplicationContext(), "Image Uploaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(SocialAuthError arg0) {
// TODO Auto-generated method stub
}
}
}
每次点击更新按钮时,吐司上都会显示“否”信息。虽然程序没有显示任何错误。如果有人可以帮我解决这个问题,我会非常感激。