Java Code Examples for com.umeng.fb.FeedbackAgent#getUserInfo()

The following examples show how to use com.umeng.fb.FeedbackAgent#getUserInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsFragment.java    From phphub-android with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPreferenceClick(Preference preference) {
    switch (preference.getKey()) {
        case "feedback":
            final FeedbackAgent agent = new FeedbackAgent(getActivity());
            agent.startFeedbackActivity();

            com.umeng.fb.model.UserInfo info = agent.getUserInfo();
            if (info == null) {
                info = new UserInfo();
            }

            Map<String, String> contact = info.getContact();
            if (contact == null) {
                contact = new HashMap<>();
            }

            if (Utils.hasLoggedIn(getActivity(), accountManager)) {
                contact.put("plain", "uid: "+ accountManager.getUserData(account, USER_ID_KEY) + " uname: "+accountManager.getUserData(account, USERNAME_KEY));

                info.setContact(contact);

                agent.setUserInfo(info);

                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        boolean result = agent.updateUserInfo();
                    }
                }).start();
            }
            return true;
        case "source_code":
            Intent intentCode = WebViewPageActivity.getCallingIntent(getActivity(), "https://github.com/phphub/phphub-android");
            getActivity().startActivity(intentCode);

            return true;
        case "about_phphub":
            Intent intentPhphub = WebViewPageActivity.getCallingIntent(getActivity(), "https://phphub.org/about");
            getActivity().startActivity(intentPhphub);

            return true;
        case "about_our_group":
            Intent intentGroup = WebViewPageActivity.getCallingIntent(getActivity(), "http://est-group.org");
            getActivity().startActivity(intentGroup);

            return true;
        case LOGOUT_KEY:
            new AlertDialog.Builder(getActivity())
                    .setMessage("确认退出吗?")
                    .setCancelable(false
                    )
                    .setPositiveButton("退出", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            JPushInterface.setAlias(getActivity().getApplicationContext(), "", null);
                            accountManager.removeAccount(Utils.getAccounts(getActivity(), accountManager)[0], null, null);
                            getPreferenceScreen().removePreference(findPreference(LOGOUT_KEY));
                        }
                    })
                    .setNegativeButton("容我想想", null)
                    .show();
            return true;
    }
    return false;
}
 
Example 2
Source File: MainActivity.java    From ONE-Unofficial with Apache License 2.0 4 votes vote down vote up
private void setUmeng() {
        //对友盟统计日志加密
        AnalyticsConfig.enableEncrypt(true);
        //友盟统计不采集mac信息
        MobclickAgent.setCheckDevice(false);

        //禁止自动提示更新对话框
        UmengUpdateAgent.setUpdateAutoPopup(false);
        //禁止增量更新
        UmengUpdateAgent.setDeltaUpdate(false);
        UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
            @Override
            public void onUpdateReturned(int status, UpdateResponse updateResponse) {
                switch (status) {
                    case UpdateStatus.Yes:
                        //有更新
                        showUpdateDialog(updateResponse);
                        break;
                    case UpdateStatus.No:
                        //无更新
                        break;
                    case UpdateStatus.NoneWifi:
                        //无wifi
                        break;
                    case UpdateStatus.Timeout:
                        //超时
                        break;
                }
            }
        });
        //友盟设置检查更新,不限于wifi
        UmengUpdateAgent.setUpdateOnlyWifi(false);
        //禁用集成检测,否则会提示缺少xxx,然而我并不需要那些东西
        UmengUpdateAgent.setUpdateCheckConfig(false);
        //检查更新
        UmengUpdateAgent.update(this);

        //同步数据
        final FeedbackAgent agent = new FeedbackAgent(this);
//        agent.openFeedbackPush();      启用推送在小米手机上会有崩溃发生
        agent.sync();
        UserInfo userInfo = agent.getUserInfo();
        String nickname = ConfigUtil.readString("user", "nickname");
        if (TextUtils.isEmpty(nickname)) {
            final String n = generateNickname();
            Map<String, String> contact = new HashMap<>();
            contact.put("昵称", n);
            userInfo.setContact(contact);
            agent.setUserInfo(userInfo);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    boolean success = agent.updateUserInfo();
                    if (success) {
                        ConfigUtil.writeString("user", "nickname", n);
                    }
                }
            }).start();

        }
        //启用推送
//        PushAgent.getInstance(this).enable();  启用推送在小米手机上会有崩溃发生
    }