有人能告诉我应该在哪里设置一个 try/catch 来捕捉这个吗?
02-10 22:54:35.701: E/ActivityThread(787): Failed to find provider info for com.facebook.katana.provider.PlatformProvider
我已经知道这是因为我没有在手机中安装 facebook 应用程序造成的。
我想在抛出异常时做一个 Toast,这是行不通的。
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();
}
}
});
我在 facebookdialog 收到异常但仍然无法正常工作的地方设置了相同的 toast。
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());
}
我应该怎么做才能为那个例外干杯?