消息未在Facebook,Twitter和Linked上发布(使用socialauth库4.4)

时间:2014-03-04 07:54:11

标签: android facebook twitter linkedin socialauth

我正试图在Facebook,Twitter和Linkedin上发布消息,但我在我的日志猫中遇到异常,即“Java.lang.nullPointerException”和“Message not posted”。没有Toast也在执行,因为有两个Toast在 MessageListener 类“执行()方法”一个是“消息发布”,另一个是“消息未发布”。我已经在我的代码中高举这些Toast,我有我尽了最大努力,但即使我已经生成了新的密钥,但它仍然没有工作,但仍然遇到同样的问题。 一个 请帮我 !! 期待回复..

这是我的代码    public View getView(int position,View convertView,ViewGroup Parent){

View vi=convertView;
 final ViewHolder holder=new ViewHolder();
 if (vi==null) {
     vi= inflater.inflate(R.layout.raw_items, null);
     Log.e("adapter","adaper set");
     final LinearLayout shareBar=(LinearLayout)                    vi.findViewById(R.id.LinearLayoutshareBar);

        adapter = new SocialAuthAdapter(new ResponseListener());  

        adapter.addProvider(Provider.FACEBOOK, R.drawable.facebook_share);
        adapter.addProvider(Provider.TWITTER,  R.drawable.tweet_button);
        adapter.addProvider(Provider.LINKEDIN, R.drawable.linkedin_share);

        adapter.enable(shareBar);


}      


}

ResponseListener类

class ResponseListener implements DialogListener
  {
String msg;

@Override
public void onError(SocialAuthError e) {
    // TODO Auto-generated method stub
     Log.d("ShareBar", e.getMessage());


}

@Override
public void onCancel() {
    // TODO Auto-generated method stub
    Log.d("ShareBar", "Authentication Cancelled");

}

@Override
public void onBack() {
    // TODO Auto-generated method stub

}

@Override
public void onComplete(Bundle values) {
    // TODO Auto-generated method stub
     final Dialog dialog = new Dialog(activity);
       dialog.setTitle("Share Message");
        dialog.setContentView(R.layout.dialog_view);

        final EditText editText = (EditText)dialog.findViewById(R.id.shareText);
        Button button = (Button)dialog.findViewById(R.id.updatebutton);    
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                msg=editText.getText().toString();
                adapter.updateStatus(msg,new MessageListener(),true); 
                dialog.dismiss();
            }
        });

        dialog.show();


}


}

MessageListener类

private final class MessageListener implements SocialAuthListener<Integer> {

@Override
public void onExecute(String provider, Integer t) {
    // TODO Auto-generated method stub
     Integer status = t;
       if (status.intValue() == 200 || status.intValue() == 201 ||status.intValue() == 204)
       **Toast.makeText(activity, "Message posted",Toast.LENGTH_LONG).show();**
       else
       **Toast.makeText(activity, "Message not posted",Toast.LENGTH_LONG).show();**
       Log.e("Execute", "I am onExecute");

}

@Override
public void onError(SocialAuthError e) {
    // TODO Auto-generated method stub
    Toast.makeText(activity,"i m error",1000).show();

}
}

0 个答案:

没有答案