public static AVUser signUp(String name, String password) throws AVException {
   AVUser user = new AVUser();
   user.setUsername(name);
   user.setPassword(password);
   user.signUp();
   return user;
 }
 private void register(final String username, final String password) {
   AVUser user = new AVUser();
   user.setUsername(username);
   user.setPassword(password);
   user.signUpInBackground(
       new SignUpCallback() {
         @Override
         public void done(AVException e) {
           LogUtil.i(TAG, "register----" + e.getMessage());
           if (e == null) {
             login(username, password);
           } else {
             showToast(e.getMessage());
           }
         }
       });
 }
 /** 手动更改密码,更改后自动重新登陆即可同步session-token */
 public void updPassword() {
   final String password = setPassword.getText().toString();
   final AVUser currentUser = AVUser.getCurrentUser();
   if (TextUtils.isEmpty(password) || currentUser == null || !currentUser.isAuthenticated())
     return;
   showLoadingDialog("正在修改密码...");
   currentUser.setPassword(password); // 修改完密码后session-token会失效(再去修改用户信息时异常),重新登陆(重置了session-token)
   currentUser.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) { // 修改成功
             cancelLoadingDialog();
             showLoadingDialog("正在重新登陆");
             AVUser.logInInBackground(
                 currentUser.getUsername(),
                 password,
                 new LogInCallback<User>() {
                   @Override
                   public void done(User newUser, AVException e) {
                     if (e == null) {
                       Utils.showToast(UserActivity.this, "重新登陆成功");
                       textView.setText(
                           "Username:"******"\n"
                               + "DisplayName:"
                               + newUser.getDisplayName()
                               + "\n");
                     } else {
                       textView.setText(e.getMessage());
                     }
                     cancelLoadingDialog();
                   }
                 },
                 User.class);
           } else {
             textView.setText(e.getMessage());
             cancelLoadingDialog();
           }
         }
       });
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    UmengUpdateAgent.update(this);

    AVUser user = new AVUser();
    user.setUsername(SAFApp.getInstance().deviceid);
    user.setPassword("default");
    user.signUpInBackground(
        new SignUpCallback() {
          public void done(AVException e) {
            if (e == null) {
              // successfully
              // Log.d("mytag","success");
            } else {
              // Log.d("mytag","fail");
            }
          }
        });

    // 各种findviews
    toolbar = (Toolbar) findViewById(R.id.tl_custom);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.mainDrawer);
    lvLeftMenu = (ListView) findViewById(R.id.lv_left_menu);

    // 初始化左侧抽屉列表
    ArrayList<MyListViewItem> listViewItems = new ArrayList<>();
    listViewItems.add(new MyListViewItem("home", "首页", "\uF015"));
    listViewItems.add(new MyListViewItem("summary", "行情概览", "\uF201"));
    listViewItems.add(new MyListViewItem("block", "板块行情", "\uF00b"));
    listViewItems.add(new MyListViewItem("mine", "自选股", "\uF21e"));
    listViewItems.add(new MyListViewItem("moni", "模拟炒股", "\uF157"));
    listViewItems.add(new MyListViewItem("about", "关于", "\uF05a"));
    listViewItems.add(new MyListViewItem("exit", "退出应用", "\uF18e"));
    adapterForDrawerListview = new adapterForDrawerListview();
    adapterForDrawerListview.setData(listViewItems);
    lvLeftMenu.setAdapter(adapterForDrawerListview);
    lvLeftMenu.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mDrawerLayout.closeDrawers();
            jumpToFragment(position);
          }
        });

    FragmentMain fragmentMain = new FragmentMain();
    this.getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.fragmentContainer, fragmentMain)
        .commit();

    toolbar.setTitle("模拟炒股CC");
    toolbar.setTitleTextColor(Color.parseColor("#ffffff")); // 设置标题颜色
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true); // 设置返回键可用
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // 创建返回键,并实现打开关/闭监听
    mDrawerToggle =
        new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.open, R.string.close) {
          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
          }

          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
          }
        };
    mDrawerToggle.syncState();
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    // Intent intentToReg = new Intent(ActivityMain.this,ActivityReg.class );
    // startActivity(intentToReg);

    UmengUpdateAgent.update(this);
  }