Exemplo n.º 1
0
 public void init() {
   String accessToken = Util.getSharePersistent(mContext, "ACCESS_TOKEN");
   if (accessToken == null || "".equals(accessToken)) {
     long appid = Long.valueOf(Util.getConfig().getProperty("APP_KEY"));
     String app_secket = Util.getConfig().getProperty("APP_KEY_SEC");
     auth(appid, app_secket);
   } else {
     shareQQweibo(accessToken);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    accessToken = Util.getSharePersistent(getApplicationContext(), "ACCESS_TOKEN");
    if (accessToken == null || "".equals(accessToken)) {
      Toast.makeText(GeneralInterfaceActivity.this, "请先授权", Toast.LENGTH_SHORT).show();
      // 进入授权
      IAPJni.authOrder(2);
      this.finish();
      return;
    }
    AccountModel account = new AccountModel(accessToken);
    friendAPI = new FriendAPI(account);
    timeLineAPI = new TimeLineAPI(account);
    weiboAPI = new WeiboAPI(account);
    userAPI = new UserAPI(account);
    lbsAPI = new LbsAPI(account);
    // 这里是粗放的错误提示,只做示例,实际应用时应该细化且友好
    mCallBack =
        new HttpCallback() {
          @Override
          public void onResult(Object object) {
            ModelResult result = (ModelResult) object;
            if (loadingWindow != null && loadingWindow.isShowing()) {

              loadingWindow.dismiss();
            }
            if (result != null && result.isSuccess()) {
              Toast.makeText(GeneralInterfaceActivity.this, "成功", Toast.LENGTH_SHORT).show();
              Intent i = new Intent(GeneralInterfaceActivity.this, GeneralDataShowActivity.class);
              i.putExtra("data", result.getObj().toString());
              startActivity(i);
            } else {
              Toast.makeText(GeneralInterfaceActivity.this, "调用失败", Toast.LENGTH_SHORT).show();
            }
          }
        };
    progressBar = new ProgressBar(this);
    loadingWindow = new PopupWindow(progressBar, 100, 100);
    context = getApplicationContext();

    mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    updateLocation(location);

    this.initInterface();
  }