I recently released my app on the marketplace. I tested it on two devices and several emulalators, and it worked fine. However, I am now getting a few crash reports with the following error:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=32665, result=-1, data=Intent { (has extras) }} to activity {com.eden.statusphere/com.eden.statussphere.FacebookConnect}: java.lang.NullPointerException
I pass only one thing to FacebookConnect: a string… here is the code. (I am using easyandroidfacebooksdk)
private OnClickListener FacebookonListener = new OnClickListener() {
public void onClick(View v) {
try{
ConnectivityManager cMgr = (ConnectivityManager) v.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cMgr.getActiveNetworkInfo();
String status = netInfo.getState().toString();
if (status.equals("CONNECTED")) {
intent.putExtra(".myMsg",statusHolder);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "No connection available",
Toast.LENGTH_SHORT).show();
}
}
catch (Exception e) {
Toast.makeText(getApplicationContext(), "Connection refused",
Toast.LENGTH_SHORT).show();
}
}
};
The above is the onClickListener, statusHolder is a string which gets passed on to my FacebookConnect activity. This is the part in FacebookConnect where the error happens:
public void loginSuccess(Facebook facebook) {
GraphApi graphApi= new GraphApi(facebook);
if(intent.getStringExtra(".myMsg")!="null"){
try {
graphApi.setStatus(intent.getStringExtra(".myMsg"));
fbManager.displayToast("Status posted!");
Intent myIntent = new Intent(this, mainActivity.class);
startActivityForResult(myIntent, 0);
} catch (EasyFacebookError e) {
e.toString();
}
} else {
fbManager.displayToast("Fatal error occured: Your device refuses to pass the information to Facebook.");
}
}
The if-else statement I just added to check if maybe the intent is getting passed as null, but I get crash reports about the same issue regardless. I have been pulling my hair out about this for quite a while. Does anyone have a clue? One device it didn’t work on was the HTC Thunderbolt.
I completely forgot about this question, but I figured I should probably document it. Anyway, it turns out it was Facebooks fault at the time. The problem solved itself after a few days of my app being on the Facebook servers.
Thought I should mention this:
Throughout the ordeal however I did a ton of searching trying to figure this out, and curiously enough, this is the same issue caused if the API key is invalid (the one you generate with keytool). So if someone is having this issue, I would suggest to make sure that their keys are all correct. If the keys are correct, wait a few days before publishing your app on the Android Market or whatever.