1

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();

}
}
kirti Hudda
  • 304
  • 3
  • 17
  • i think you have not created your secret key and consumer key correctly.,check that again.. – rajshree Mar 04 '14 at 07:58
  • I have tried that also and my key is correct because if i work with a new seperate application with the same key which i generated for this application then it works .Message get posted correctly. I tried this for Facebook. – kirti Hudda Mar 04 '14 at 08:15
  • @kirtiHudda try as per my answer and let me know – M D Mar 04 '14 at 09:11
  • @Simple Plan its written there in my getView()..actually i put only the code i.e related to share function..I have lots of thing in my getView() thats why i didn't put my complete getView(). – kirti Hudda Mar 04 '14 at 09:25
  • initialize socialauth adapter in on create , using in getview is wrong practice and that may be causing the issue. – vineet Mar 26 '14 at 07:46

0 Answers0