Domanda

Can someone tell me where should i set a try/catch to catch this?

02-10 22:54:35.701: E/ActivityThread(787): Failed to find provider info for com.facebook.katana.provider.PlatformProvider

I already know that it is caused because I have not installed the facebook application in the cellphone.

I want to make a Toast when the exception is throwed this do not work.

shareButton.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {

            // TODO Auto-generated method stub
            try{
            FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(Archivo.this)
            .setLink(pagina)
            .setName(nombre)
            .setPicture(photo)
            .setDescription(brief)
            .build();
            uiHelper.trackPendingDialogCall(shareDialog.present());
            }
            catch(FacebookDialogException ex){
                int duration = Toast.LENGTH_SHORT;
            CharSequence FacebookDialogError="Instale y actualize su version de Facebook";
            Toast toast = Toast.makeText(activity,FacebookDialogError , duration);
            toast.show();

            }
        }
    });

I set te same toast in where the facebookdialog receive a exception and it still not working.

 public FacebookDialog build() {
        validate();

        Bundle extras = new Bundle();
        putExtra(extras, NativeProtocol.EXTRA_APPLICATION_ID, applicationId);
        putExtra(extras, NativeProtocol.EXTRA_APPLICATION_NAME, applicationName);

        Intent intent = handleBuild(extras);
        if (intent == null) {
            int duration = Toast.LENGTH_SHORT;
            CharSequence FacebookDialogError="Instale y aCtualize su version de Facebook";
            Toast toast = Toast.makeText(activity,FacebookDialogError , duration);
            toast.show();
            throw new FacebookException("Unable to create Intent; this likely means the Facebook app is not installed.");
        }
        appCall.setRequestIntent(intent);

        return new FacebookDialog(activity, fragment, appCall, getOnPresentCallback());
    }

What should I do to make a Toast of that exception?

È stato utile?

Soluzione

Sorry if it is too late to answer my own question, but I am about to update the app in where this question came out. Since the question is still watched I will post the a troubleshooting

This is a fallback in case of the Facebook app is not found.

    private void publishFeedDialog(String Link,String Name,String Photo,String Descripcion) {

    Bundle params = new Bundle();
    params.putString("name", Name);
    params.putString("caption",Caption);
    params.putString("description",Descripcion);
    params.putString("link", Link);
    params.putString("picture",Photo);

    WebDialog feedDialog = (
            new WebDialog.FeedDialogBuilder(sEstablecimiento.this,
                    Session.getActiveSession(),
                    params))
            .setOnCompleteListener(new OnCompleteListener() {

                @Override
                public void onComplete(Bundle values,
                                       FacebookException error) {
                    if (error == null) {
                        final String postId = values.getString("post_id");
                        if (postId != null) {
                            Toast.makeText(sEstablecimiento.this,
                                    "Posted story, id: "+postId,
                                    Toast.LENGTH_SHORT).show();
                        } else {
                            // User clicked the Cancel button
                            Toast.makeText(sEstablecimiento.this.getApplicationContext(),
                                    "Publish cancelled",
                                    Toast.LENGTH_SHORT).show();
                        }
                    } else if (error instanceof FacebookOperationCanceledException) {
                        // User clicked the "x" button
                        Toast.makeText(sEstablecimiento.this.getApplicationContext(),
                                "Publish cancelled",
                                Toast.LENGTH_SHORT).show();
                    } else {
                        // Generic, ex: network error
                        Toast.makeText(sEstablecimiento.this.getApplicationContext(),
                                "Error posting story",
                                Toast.LENGTH_SHORT).show();
                    }
                }

            })
            .build();
    feedDialog.show();
}

And use a boolean to test if the ShareDialog can be buil

if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
                                FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {

                            FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(myActivity.this)
                                    .setLink("page")
                                    .setName("name")
                                    .setPicture("photo")
                                    .setDescription("description")
                                    .build();
                            uiHelper.trackPendingDialogCall(shareDialog.present());

                        } else {
                            publishFeedDialog("page","name","photo","description");
                        }

I hope it could be usefull for someone. Thanks for your pathience an forgive my lack of care about the question.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top