Skip to content

Instantly share code, notes, and snippets.

@ChrisRisner
Last active December 14, 2015 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisRisner/5027956 to your computer and use it in GitHub Desktop.
Save ChrisRisner/5027956 to your computer and use it in GitHub Desktop.
Android Auth
private void authenticate() {
// Login using the Google provider.
mClient.login(MobileServiceAuthenticationProvider.Google,
new UserAuthenticationCallback() {
@Override
public void onCompleted(MobileServiceUser user,
Exception exception, ServiceFilterResponse response) {
if (exception == null) {
createAndShowDialog(String.format(
"You are now logged in - %1$2s",
user.getUserId()), "Success");
createTable();
} else {
createAndShowDialog("You must log in. Login Required", "Error");
}
}
});
}
private void createTable() {
// Get the Mobile Service Table instance to use
mToDoTable = mClient.getTable(ToDoItem.class);
mTextNewToDo = (EditText) findViewById(R.id.textNewToDo);
// Create an adapter to bind the items with the view
mAdapter = new ToDoItemAdapter(this, R.layout.row_list_to_do);
ListView listViewToDo = (ListView) findViewById(R.id.listViewToDo);
listViewToDo.setAdapter(mAdapter);
// Load the items from the Mobile Service
refreshItemsFromTable();
}
function insert(item, user, request) {
item.userId = user.userId;
request.execute();
}
function read(query, user, request) {
query.where({userId : user.userId});
request.execute();
}
import com.microsoft.windowsazure.mobileservices.MobileServiceUser;
import com.microsoft.windowsazure.mobileservices.MobileServiceAuthenticationProvider;
import com.microsoft.windowsazure.mobileservices.UserAuthenticationCallback;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment