注释掉几乎所有内容仍然找不到空值??我只在 2.1 上得到这个错误,任何更高的都运行良好??谢谢您的帮助。
public class BizProfiles extends Activity {
private Button button;
private Button btnFbLogin;
private Button btnPostToWall;
private Button btnTLogin;
// Facebook APP ID
private static String APP_ID = "App ID here"; //
// Instance of Facebook Class
private Facebook facebook;
@SuppressWarnings("unused")
private AsyncFacebookRunner mAsyncRunner;
String FILENAME = "AndroidSSO_data";
private SharedPreferences mPrefs;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
final Context context = this;
super.onCreate(savedInstanceState);
facebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(facebook);
/////////////////////////////////////////////////////////////////////////////////
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
if (width == 320 && height == 480)
{
setContentView(R.layout.bizprofiles320);
Log.v("blah", "320 layout");
}
else
{
Log.v("blah", "480 800 layout");
setContentView(R.layout.bizprofiles);
//////
}
// String name = getIntent().getExtras().getString("BizName");
// String address = getIntent().getExtras().getString("BizAddress");
// String phone = getIntent().getExtras().getString("BizPhone");
// String about = getIntent().getExtras().getString("BizAbout");
// String monfri = getIntent().getExtras().getString("BizMonFri");
// String satsun = getIntent().getExtras().getString("BizSatSun");
// String imgname = getIntent().getExtras().getString("BizImg");
// final String website = getIntent().getExtras().getString("BizWeb");
//////
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent intent = new Intent(context, BizWebSite.class);
// intent.putExtra("BizWeb", website.toString());
startActivity(intent);
} });
btnFbLogin = (Button) findViewById(R.id.button2);
btnFbLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
loginToFacebook();
}
});
btnPostToWall = (Button) findViewById(R.id.Button01);
btnPostToWall.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
postToWall();
}
});
btnTLogin = (Button) findViewById(R.id.tlogin);
btnTLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Intent intent = new Intent(context, TweetPage.class);
// // intent.putExtra("BizWeb", website.toString());
// startActivity(intent);
new Twitter_Dialog(BizProfiles.this,"http://twitter.com/?status="+Uri.encode("Twitter Post")).show();
}
});
// String getimg = imgname;
// int resID = getResources().getIdentifier(imgname, "drawable", "com.RforR.ForPlay1");
// ImageView image = (ImageView) findViewById(R.id.imageView3); //null;
// image.setImageResource(resID);
//System.out.println(resID);
//Log.v("blah*************", resID);
// AutoResizeTextView obtar = new AutoResizeTextView(context);
// obtar tvme = (TextView) findViewById(R.id.tvName);
// TextView theTextView = (TextView) findViewById(R.id.tvName);
// theTextView.setText(name);
// TextView theAdd = (TextView) findViewById(R.id.tvAddress);
// theAdd.setText(address);
// TextView thePhone = (TextView) findViewById(R.id.tvPhone);
// thePhone.setText(phone);
}
public void onGetNames(View gn)
{
// String name = getIntent().getExtras().getString("BizName");
// String address = getIntent().getExtras().getString("BizAddress");
// String phone = getIntent().getExtras().getString("BizName");
// String about = getIntent().getExtras().getString("BizAbout");
// String monfri = getIntent().getExtras().getString("BizMonFri");
// String satsun = getIntent().getExtras().getString("BizSatSun");
//
// System.out.println(name);
// System.out.println(about);
// System.out.println(satsun);
Log.v("blah", "blah blah");
}
public void loginToFacebook() {
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if (access_token != null) {
facebook.setAccessToken(access_token);
}
if (expires != 0) {
facebook.setAccessExpires(expires);
}
if (!facebook.isSessionValid()) {
facebook.authorize(this,
new String[] { "email", "publish_stream" },
new DialogListener() {
public void onCancel() {
// Function to handle cancel event
}
public void onComplete(Bundle values) {
// Function to handle complete event
// Edit Preferences and update facebook acess_token
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token",
facebook.getAccessToken());
editor.putLong("access_expires",
facebook.getAccessExpires());
editor.commit();
}
public void onError(DialogError error) {
// Function to handle error
}
public void onFacebookError(FacebookError fberror) {
// Function to handle Facebook errors
}
});
}
}
public void postToWall() {
// post on user's wall.
facebook.dialog(this, "feed", new DialogListener() {
public void onFacebookError(FacebookError e) {
}
public void onError(DialogError e) {
}
public void onComplete(Bundle values) {
}
public void onCancel() {
}
});
}
public void onGoBk(View cc)
{
finish();
}
}
日志猫