Facebook Posting Error in Android
<p>I have a problem that I am posting a string message on the Facebook but get Some Error while posting I don't know why because same code is running in different project. Please help me regarding this.</p>

<p><strong>Error Stack:</strong></p>

<pre><code>10-19 11:40:43.065: ERROR/AndroidRuntime(7466): FATAL EXCEPTION: main
10-19 11:40:43.065: ERROR/AndroidRuntime(7466): java.lang.NullPointerException
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at com.halosys.TvAnyTime.VideoPlayer$7.onClick(VideoPlayer.java:304)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at android.view.View.performClick(View.java:2408)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at android.view.View$PerformClick.run(View.java:8818)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at android.os.Handler.handleCallback(Handler.java:587)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at android.os.Looper.loop(Looper.java:123)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at java.lang.reflect.Method.invokeNative(Native Method)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at java.lang.reflect.Method.invoke(Method.java:521)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-19 11:40:43.065: ERROR/AndroidRuntime(7466):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p><strong>New Code:</strong></p>

<p>//Bundle parameters = new Bundle();
                        String str_post=null;
                        if(rating.equals(""))
                        {
                            str_post = "TV Anytime lets you watch the shows and movies you love on your iPhone, iPad or PC for free without the need for a network. TVAnytime is the first FREE streaming video DVR for your iPhone, iPad or PC.\n"+name+" just watched "+MovieName+" on iPhone with TvAnytime!\n"+ed_Post.getText().toString()+"";
                        }else
                        {
                            str_post = "TV Anytime lets you watch the shows and movies you love on your iPhone, iPad or PC for free without the need for a network. TVAnytime is the first FREE streaming video DVR for your iPhone, iPad or PC.\n"+name+" just watched "+MovieName+" on iPhone with TvAnytime!\n"+ed_Post.getText().toString()+"\nRating "+rating+" out of 5";
                        }
                        //parameters.putString("message", str_post);
                        //IntroFaceBookScreen.mFacebook.authorize(VideoPlayer.this, new String[]{"publish_stream", "read_stream", "offline_access"},IntroFaceBookScreen.mFacebook.FORCE_DIALOG_AUTH,new FacebookDialogListener(VideoPlayer.this));
                        /*String response = null;
                        try {
                            response = mFacebook.request("me");
                        } catch (MalformedURLException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        Bundle parameters = new Bundle();
                        parameters.putString("message", str_post);
                        //posting image code</p>

<pre><code>                    Bitmap bm = BitmapFactory.decodeFile("/sdcard/showIcon/show_S00275.png");
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();  
                    bm.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm is the bitmap object   
                    byte[] imgData = baos.toByteArray(); 


                    parameters.putByteArray("picture", imgData);




                    parameters.putString("description", "test test test");
                    try {

                        response = mFacebook.request("me/feed", parameters, "POST");
                    } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (MalformedURLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    Log.d("Tests", "got response: " + response);
                    if (response == null || response.equals("") || 
                            response.equals("false")) {
                       Log.v("Error", "Blank response");
                    }*/
                    post_to_wall(str_post);
                    /* mFacebook.dialog(VideoPlayer.this, "feed",
                                new SampleDialogListener());*/
                    dismissDialog(0);
                }
            });

        btn_Cancel.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {

                removeDialog(0);
            }
        });

        break;
}
return dialog;
</code></pre>

<p>}
protected void post_to_wall(String str_post) {</p>

<pre><code> try{
      Bitmap bm = BitmapFactory.decodeFile("/sdcard/showIcon/show_S00275.png");
      ByteArrayOutputStream baos = new ByteArrayOutputStream();  
      bm.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm is the bitmap object   
      byte[] imgData = baos.toByteArray(); 
      Bundle parameters = new Bundle();
      parameters.putString("message", "Test Post in Facebook Wal");
      parameters.putString("description", str_post);
      parameters.putByteArray("picture", imgData);
      String  response = mFacebook.request("me/feed",parameters,"POST");       
      Log.v("response", response);
   }
   catch(Exception e){
       System.out.println("The error Message = "+e);
   }
</code></pre>

<p>}</p>
