Last active
December 14, 2015 04:28
-
-
Save ChrisRisner/5027956 to your computer and use it in GitHub Desktop.
Android Auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function insert(item, user, request) { | |
item.userId = user.userId; | |
request.execute(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function read(query, user, request) { | |
query.where({userId : user.userId}); | |
request.execute(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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