I am trying to post message on Facebook, Twitter and Linkedin, but I am getting exception in my log cat i.e "Java.lang.nullPointerException" and "Message not posted" .No Toast is also executing as there are two Toast in MessageListener class "execute() method" one is "message posted" and another one is "message not posted".I have highligted these Toast in my code, I have tried my best but its not working even i have generated new keys also but still getting the same problem. a Please help me !! Looking forward for reply..
Here is my code 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
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 Class
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();
}
}