How to register a new user on XMPP using (a)Smack library

前端 未结 9 1103
南笙
南笙 2020-12-28 19:10

I have set up a xmpp server and android client using the great post here... I have some pre defined users set up in the xmpp server and i could login with those credentials.

9条回答
  •  旧巷少年郎
    2020-12-28 19:34

    If you are using latest version then use this one.

    new Thread() {
                        @Override
                        public void run() {
                            try {
                                AccountManager accountManager = AccountManager.getInstance(mConnection);
                                accountManager.sensitiveOperationOverInsecureConnection(true);
                                Map map = new HashMap();
                                map.put("username","vinay");
                                map.put("name", "vinay");
                                map.put("password", "vinay");
                                map.put("emial", "vinay@gmail.com");
                                accountManager.createAccount(Localpart.from("vinay"), "vinay", map);
                            } catch (SmackException.NoResponseException e) {
                                e.printStackTrace();
                            } catch (XMPPException.XMPPErrorException e) {
                                e.printStackTrace();
                            } catch (SmackException.NotConnectedException e) {
                                e.printStackTrace();
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            } catch (XmppStringprepException e) {
                                e.printStackTrace();
                            }
    
                        }
                    }.start();
    

提交回复
热议问题