public class MainActivity extends Activity implements StatusCallback { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); OpenRequest open = new OpenRequest(this); open.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO); open.setPermissions(Arrays.asList(new String[]{"email", "publish_actions", "user_birthday", "user_hometown"})); open.setCallback(this); Session s = new Session(this); s.openForPublish(open); } @Override public void call(Session session, SessionState state, Exception exception) { } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(Session.getActiveSession()!=null) Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); } }
try (Session session = new Session()) { // do stuff }
/** * Get a new Session object. * * @param props Properties object that hold relevant properties.<br> * It is expected that the client supplies values * for the properties listed in Appendix A of the * JavaMail spec (particularly mail.store.protocol, * mail.transport.protocol, mail.host, mail.user, * and mail.from) as the defaults are unlikely to * work in all cases. * @return a new Session object * @since JavaMail 1.2 */ public static Session getInstance(Properties props) { return new Session(props, null); }
/** * Get a new Session object. * * @param props Properties object that hold relevant properties.<br> * It is expected that the client supplies values * for the properties listed in Appendix A of the * JavaMail spec (particularly mail.store.protocol, * mail.transport.protocol, mail.host, mail.user, * and mail.from) as the defaults are unlikely to * work in all cases. * @return a new Session object * @since JavaMail 1.2 */ public static Session getInstance(Properties props) { return new Session(props, null); }
/** * Get a new Session object. * * @param props Properties object that hold relevant properties.<br> * It is expected that the client supplies values * for the properties listed in Appendix A of the * JavaMail spec (particularly mail.store.protocol, * mail.transport.protocol, mail.host, mail.user, * and mail.from) as the defaults are unlikely to * work in all cases. * @param authenticator Authenticator object used to call back to * the application when a user name and password is * needed. * @return a new Session object * @see javax.mail.Authenticator */ public static Session getInstance(Properties props, Authenticator authenticator) { return new Session(props, authenticator); }
/** * Get a new Session object. * * @param props Properties object that hold relevant properties.<br> * It is expected that the client supplies values * for the properties listed in Appendix A of the * JavaMail spec (particularly mail.store.protocol, * mail.transport.protocol, mail.host, mail.user, * and mail.from) as the defaults are unlikely to * work in all cases. * @param authenticator Authenticator object used to call back to * the application when a user name and password is * needed. * @return a new Session object * @see javax.mail.Authenticator */ public static Session getInstance(Properties props, Authenticator authenticator) { return new Session(props, authenticator); }
Session session = new Session(this); session.openForRead(new Session.OpenRequest(this) .setCallback(statusCallback) .setPermissions(Arrays.asList("friends_birthday")));
Session session = new Session(this); Session.setActiveSession(session); session.openForRead(new Session.OpenRequest(this).setCallback(callback).setPermissions(Arrays.asList("your_permissions")));
if (security != null) security.checkSetFactory(); defaultSession = new Session(props, authenticator); } else {
if (security != null) security.checkSetFactory(); defaultSession = new Session(props, authenticator); } else {
session = new Session(this);
var test = new Session(); test.callbackWhenSet("a_dep", function () { alert("a_dep is set to " + test.get("a_dep")); }); test.set("a_dep", 10); test.set("something", 250); test.set("a_dep", 20);
// Controller public static Result load() { System.out.println("in load1"); session = new Session(); changeLang("fr"); return ok(mainpage.render(messages.generate("window.Messages"))); } // Template: @(messages: String) <script type="text/javascript">@messages</script>
Session session = new Session(this); // <-- where "this" is a reference to your Activity, or Context Session.OpenRequest request = new Session.OpenRequest(this).setPermissions("basic_info", "email"); openRequest.setCallback(new Session.StatusCallback() { ... // Put your callback code here }); Session.setActiveSession(session); session.openForRead(request);
Session s = new Session(...); for(int i = 0; i < MAX_TRIES; i++) { try { s.connect(); break; } catch(JSchException ex) { if(i == MAX_TRIES - 1) throw ex; continue; } }
Session s = new Session(this); Session.setActiveSession(s); Session.OpenRequest request = new Session.OpenRequest(this); request.setPermissions(Arrays.asList("basic_info","email")); request.setCallback( /* your callback here */ ); s.openForRead(request);
Session s = new Session(this); Session.setActiveSession(s); Session.OpenRequest request = new Session.OpenRequest(this); request.setPermissions(...); // Note that you cannot set email AND publish_actions in the same request request.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO); request.setCallback(...); s.openForRead(request);
Session session = Session.getActiveSession(); if (session == null) { if (savedInstanceState != null) { session = Session.restoreSession(this, null, statusCallback, savedInstanceState); } if (session == null) { session = new Session(this); } Session.setActiveSession(session); if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) { session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback)); } }
Session session = Session.getActiveSession(); if (session == null) { session = new Session(this); Session.setActiveSession(session); } if (!session.isOpened() && !session.isClosed())) { session.openForRead(new Session.OpenRequest(this) .setPermissions(Arrays.asList("basic_info","email")) .setCallback(statusCallback)); }
Session studentDbSession = new Session("localhost",5984); Database studentCouchDb = studentDbSession.getDatabase("student"); Document newdoc = new Document(); HashMap<String , String> properties = new HashMap<String,String>(); newdoc.setId("c0b3457b1d6e5f8431d62a31fd00073c"); newdoc.put("Name", "Priya"); properties.put("10th", "69.9"); properties.put("12th", "62.83"); properties.put("Graduation", "69.73"); properties.put("Post_Graduation", "71.55"); newdoc.put("Education", properties); studentCouchDb.saveDocument(newdoc);