Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to Succeed In Android Development

7bf2baf0d8d5d7d96e6b67c5d567e3f9?s=47 Caren
December 31, 2018
450

How to Succeed In Android Development

7bf2baf0d8d5d7d96e6b67c5d567e3f9?s=128

Caren

December 31, 2018
Tweet

Transcript

  1. How to Succeed In This Course

  2. Keys to Success 1) Learn how to debug code 2)

    Understand the code you write 3) Ask for help 4) Be familiar with Android Studio
  3. Keys to Success 1) Learn how to debug code 2)

    Understand the code you write 3) Ask for help 4) Be familiar with Android Studio
  4. Debugging Code If you don’t know how to start debugging

    your own code, it’s always going to be an uphill battle
  5. Debugging Code If you don’t know how to start debugging

    your own code, it’s always going to be an uphill battle Android Studio is your friend, don’t ignore the messages it gives you
 Did your app successfully build?
 What are the messages that prints out when your app crashes?
  6. Debugging Code If you don’t know how to start debugging

    your own code, it’s always going to be an uphill battle Android Studio is your friend, don’t ignore the messages it gives you
 Did your app successfully build?
 What are the messages that prints out when your app crashes? At what point does your code ‘stop’ working as expected? 
 Log messages will do wonders

  7. Keys to Success 1) Learn how to debug code 2)

    Understand the code you write 3) Ask for help 4) Be familiar with Android Studio
  8. Understand the Code You Write Avoid blindly copy and pasting

    code that works
  9. Understand the Code You Write Avoid blindly copy and pasting

    code that works Take the extra time to understand the purpose of each block
  10. Understand the Code You Write Avoid blindly copy and pasting

    code that works Take the extra time to understand the purpose of each block Write comments in your code to so you can
 1) gain a better understanding of what the code is 
 trying to accomplish
 2) understand what your past-self was trying to do
  11. Example: We are working on our ToDo app and we

    want to add the feature to edit a task (when user clicks on an item in the list, launch another screen to let them edit the item) Understand the Code You Write
  12. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task (when user clicks on an item in the list, launch another screen to let them edit the item) First, let’s think about what we need to do:

  13. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task First, let’s think about what we need to do:
 1) Attach an onClickListener() for each item so that when an item is clicked, it takes the user to a new screen to edit the task

  14. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task First, let’s think about what we need to do:
 1) Attach an onClickListener() for each item so that when an item is clicked, it takes the user to a new screen to edit the task
 2) When we launch the new screen, we also need to pass it the item (the string) that the user clicked on

  15. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task First, let’s think about what we need to do:
 1) Attach an onClickListener() for each item so that when an item is clicked, it takes the user to a new screen to edit the task
 2) When we launch the new screen, we also need to pass it the item (the string) that the user clicked on
 3) In the new ‘edit’ screen, once the user taps ‘done’, we need to pass back the newly edited item (the string) to the MainActivity

  16. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task First, let’s think about what we need to do:
 1) Attach an onClickListener() for each item so that when an item is clicked, it takes the user to a new screen to edit the task
 2) When we launch the new screen, we also need to pass it the item (the string) that the user clicked on
 3) In the new ‘edit’ screen, once the user taps ‘done’, we need to pass back the newly edited item (the string) to the MainActivity
 4) In MainActivity, once we get back the result of the edit, we need to update the item in the list

  17. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task First, let’s think about what we need to do:
 1) Attach an onClickListener() for each item so that when an item is clicked, it takes the user to a new screen to edit the task
 2) When we launch the new screen, we also need to pass it the item (the string) that the user clicked on
 3) In the new ‘edit’ screen, once the user taps ‘done’, we need to pass back the newly edited item (the string) to the MainActivity
 4) In MainActivity, once we get back the result of the edit, we need to update the item in the list
 Oh no, but how do we know which item to ‘update’?
  18. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task First, let’s think about what we need to do:
 1) Attach an onClickListener() for each item so that when an item is clicked, it takes the user to a new screen to edit the task AND save item’s position
 2) When we launch the new screen, we also need to pass it the item (the string) that the user clicked on
 3) In the new ‘edit’ screen, once the user taps ‘done’, we need to pass back the newly edited item (the string) to the MainActivity
 4) In MainActivity, once we get back the result of the edit, we need to update the item in the list
 Oh no, but how do we know which item to ‘update’? Now we realize we also need to save the original item’s position so we can update it.
  19. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later)
  20. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) MainActivity EditItemActivity
  21. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) // set up onClickListener for each item in list to take user to new EditItemActivity MainActivity EditItemActivity
  22. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) // set up onClickListener for each item in list to take user to new EditItemActivity // inside onClickListener: // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) MainActivity EditItemActivity
  23. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) // set up onClickListener for each item in list to take user to new EditItemActivity // inside onClickListener: // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) // in onActivityResult: // 1) grab updated string and update it in the list of items MainActivity EditItemActivity
  24. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) // set up onClickListener for each item in list to take user to new EditItemActivity // inside onClickListener: // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) // in onActivityResult: // 1) grab updated string and update it in the list of items // in onCreate(), get the string passed from MainActivity and display it in the EditTextView MainActivity EditItemActivity
  25. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) // set up onClickListener for each item in list to take user to new EditItemActivity // inside onClickListener: // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) // in onActivityResult: // 1) grab updated string and update it in the list of items // in onCreate(), get the string passed from MainActivity and display it in the EditTextView // set onClickListener for 'done' button to pass back newly edited string MainActivity EditItemActivity
  26. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) // set up onClickListener for each item in list to take user to new EditItemActivity // inside onClickListener: // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) // in onActivityResult: // 1) grab updated string and update it in the list of items // in onCreate(), get the string passed from MainActivity and display it in the EditTextView // set onClickListener for 'done' button to pass back newly edited string MainActivity EditItemActivity
  27. Understand the Code You Write // set up onClickListener for

    each item in list to take user to new EditItemActivity // inside onClickListener… // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) // in onActivityResult: // 1) grab updated string and update it in the list of items MainActivity
  28. Understand the Code You Write // set up onClickListener for

    each item in list to take user to new EditItemActivity ((ListView) findViewById(R.id.lvItems)).setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) } }); // in onActivityResult: // 1) grab updated string and update it in the list of items MainActivity
  29. Understand the Code You Write // set up onClickListener for

    each item in list to take user to new EditItemActivity ((ListView) findViewById(R.id.lvItems)).setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // 1) pass EditItemActivity string to be edited Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); // 2) save position of item clicked on (to update the correct item later) } }); // in onActivityResult: // 1) grab updated string and update it in the list of items MainActivity
  30. Understand the Code You Write // set up onClickListener for

    each item in list to take user to new EditItemActivity int editingItemPosition = 0; ((ListView) findViewById(R.id.lvItems)).setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // 1) pass EditItemActivity string to be edited Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); // 2) save position of item clicked on (to update the correct item later) editingItemPosition = position; } }); // in onActivityResult: // 1) grab updated string and update it in the list of items MainActivity
  31. Understand the Code You Write // set up onClickListener for

    each item in list to take user to new EditItemActivity int editingItemPosition = 0; ((ListView) findViewById(R.id.lvItems)).setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // 1) pass EditItemActivity string to be edited Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); // 2) save position of item clicked on (to update the correct item later) editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); // in onActivityResult: // 1) grab updated string and update it in the list of items MainActivity
  32. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) // set up onClickListener for each item in list to take user to new EditItemActivity // inside onClickListener: // 1) pass EditItemActivity string to be edited // 2) save position of item clicked on (to update the correct item later) // in onActivityResult: // 1) grab updated string and update it in the list of items // in onCreate(), get the string passed from MainActivity and display it in the EditTextView // set onClickListener for 'done' button to pass back newly edited string MainActivity EditItemActivity
  33. Understand the Code You Write // in onCreate(), get the

    string passed from MainActivity and display it in the EditTextView // set onClickListener for 'done' button to pass back newly edited string EditItemActivity
  34. Understand the Code You Write @Override protected void onCreate(Bundle savedInstanceState)

    { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_item); // get the string passed from MainActivity and display it in the EditTextView // set onClickListener for 'done' button to pass back newly edited string } EditItemActivity
  35. Understand the Code You Write @Override protected void onCreate(Bundle savedInstanceState)

    { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_item); // get the string passed from MainActivity and display it in the EditTextView String oldText = getIntent().getStringExtra("oldItem"); ((EditText) findViewById(R.id.etNewItem)).setText(oldText); // set onClickListener for 'done' button to pass back newly edited string } EditItemActivity
  36. Understand the Code You Write @Override protected void onCreate(Bundle savedInstanceState)

    { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_item); // get the string passed from MainActivity and display it in the EditTextView String oldText = getIntent().getStringExtra("oldItem"); ((EditText) findViewById(R.id.etNewItem)).setText(oldText); // set onClickListener for 'done' button to pass back newly edited string findViewById(R.id.btnSave).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EditText etNewItem = findViewById(R.id.editText1); Intent data = new Intent(); data.putExtra("newItem", etNewItem.getText().toString()); setResult(RESULT_OK, data); finish(); } }); } EditItemActivity
  37. Understand the Code You Write // set up onClickListener for

    each item in list to take user to new EditItemActivity int editingItemPosition = 0; ((ListView) findViewById(R.id.lvItems)).setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // 1) pass EditItemActivity string to be edited Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); // 2) save position of item clicked on (to update the correct item later) editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); // in onActivityResult: // 1) grab updated string and update it in the list of items MainActivity
  38. Understand the Code You Write // set up onClickListener for

    each item in list to take user to new EditItemActivity int editingItemPosition = 0; ((ListView) findViewById(R.id.lvItems)).setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // 1) pass EditItemActivity string to be edited Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); // 2) save position of item clicked on (to update the correct item later) editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) { // 1) grab updated string and update it in the list of items String newItem = data.getExtras().getString("item"); items.set(editingItemPosition, newItem); itemsAdapter.notifyDataSetChanged(); } } MainActivity
  39. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) Approach #2 : If you have code that already works, tag it with comments to make sure you understand it
  40. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task Approach #1 : Translate thought process into comments first (to be translated into code later) Approach #2 : If you have code that already works, tag it with comments to make sure you understand it.
 - if you don’t understand the code, look up guides and resources to help you bridge the gap
  41. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 private int editingItemPosition = 0; lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); MainActivity
  42. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 private int editingItemPosition = 0; // when an item is clicked, take user to EditItemActivity with task/string to edit lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); MainActivity
  43. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 private int editingItemPosition = 0; // when an item is clicked, take user to EditItemActivity with task/string to edit lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // prepare to go to EditItemActivity Intent i = new Intent(MainActivity.this, EditItemActivity.class); i.putExtra("oldItem", items.get(position)); editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); MainActivity
  44. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 private int editingItemPosition = 0; // when an item is clicked, take user to EditItemActivity with task/string to edit lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // prepare to go to EditItemActivity Intent i = new Intent(MainActivity.this, EditItemActivity.class); // also send EditItemActivity the string to edit, with key 'oldItem' i.putExtra("oldItem", items.get(position)); editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); MainActivity
  45. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 private int editingItemPosition = 0; // when an item is clicked, take user to EditItemActivity with task/string to edit lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // prepare to go to EditItemActivity Intent i = new Intent(MainActivity.this, EditItemActivity.class); // also send EditItemActivity the string to edit, with key 'oldItem' i.putExtra("oldItem", items.get(position)); // save the position of the item we're editing to know which item to update later editingItemPosition = position; startActivityForResult(i, REQUEST_CODE); } }); MainActivity
  46. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 private int editingItemPosition = 0; // when an item is clicked, take user to EditItemActivity with task/string to edit lvItems.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // prepare to go to EditItemActivity Intent i = new Intent(MainActivity.this, EditItemActivity.class); // also send EditItemActivity the string to edit, with key 'oldItem' i.putExtra("oldItem", items.get(position)); // save the position of the item we're editing to know which item to update later editingItemPosition = position; // launch EditItemActivity with request code 100, we use this onActivityResult() 
 // later startActivityForResult(i, 100); } }); MainActivity
  47. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_item); String oldText = getIntent().getStringExtra("oldItem"); ((EditText) findViewById(R.id.editText1)).setText(oldText); findViewById(R.id.btnSave).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EditText etNewItem = findViewById(R.id.editText1); Intent data = new Intent(); data.putExtra("newItem", etNewItem.getText().toString()); setResult(RESULT_OK, data); finish(); } }); } EditItemActivity
  48. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_item); // set the EditText field to the string passed from MainActivity // “oldItem” was the key set from MainActivity String oldText = getIntent().getStringExtra("oldItem"); ((EditText) findViewById(R.id.editText1)).setText(oldText); findViewById(R.id.btnSave).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EditText etNewItem = findViewById(R.id.editText1); Intent data = new Intent(); data.putExtra("newItem", etNewItem.getText().toString()); setResult(RESULT_OK, data); finish(); } }); } EditItemActivity
  49. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_item); // set the EditText field to the string passed from MainActivity // “oldItem” was the key set from MainActivity String oldText = getIntent().getStringExtra("oldItem"); ((EditText) findViewById(R.id.editText1)).setText(oldText); findViewById(R.id.btnSave).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // grab the text in the EditText field and send it to MainActivity with key
 // ‘newItem’ EditText etNewItem = findViewById(R.id.editText1); Intent data = new Intent(); data.putExtra("newItem", etNewItem.getText().toString()); setResult(RESULT_OK, data); finish(); } EditItemActivity
  50. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) { String newItem = data.getExtras().getString("newItem"); items.set(editingItemPosition, newItem); itemsAdapter.notifyDataSetChanged(); } } MainActivity
  51. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) { // get the edited text passed from EditItemActivity // “newItem” was the key set from EditItemActivity String newItem = data.getExtras().getString("newItem"); items.set(editingItemPosition, newItem); itemsAdapter.notifyDataSetChanged(); } } MainActivity
  52. Understand the Code You Write Example: We are working on

    our ToDo app and we want to add the feature to edit a task
 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) { // get the edited text passed from EditItemActivity // “newItem” was the key set from EditItemActivity String newItem = data.getExtras().getString(“newItem"); // update the appropriate item with the position we saved earlier items.set(editingItemPosition, newItem); itemsAdapter.notifyDataSetChanged(); } } MainActivity
  53. Understand the Code You Write 1) Think about what you

    need to do before you start writing code
 

  54. Understand the Code You Write 1) Think about what you

    need to do before you start writing code
 
 2) Write comments before you write code to help get the main idea down
 

  55. Understand the Code You Write 1) Think about what you

    need to do before you start writing code
 
 2) Write comments before you write code to help get the main idea down
 
 3) Go back and tag code with comments to make sure you understand your code
  56. Keys to Success 1) Learn how to debug code 2)

    Understand the code you write 3) Ask for help 4) Be familiar with Android Studio
  57. Asking for help The key to accelerate learning is by

    leveraging support
  58. Asking for help The key to accelerate learning is by

    leveraging support It’s not worth being stuck for more than an hour: ask your classmates or post for help
  59. Asking for help The key to accelerate learning is by

    leveraging support It’s not worth being stuck for more than an hour: ask your classmates or post for help Help people help you: Don’t say ‘My app doesn’t work’

  60. Asking for help The key to accelerate learning is by

    leveraging support It’s not worth being stuck for more than an hour: ask your classmates or post for help Help people help you: Don’t say ‘My app doesn’t work’
 - specific explanation of what you are trying to do and what happened instead

  61. Asking for help The key to accelerate learning is by

    leveraging support It’s not worth being stuck for more than an hour: ask your classmates or post for help Help people help you: Don’t say ‘My app doesn’t work’
 - specific explanation of what you are trying to do and what happened instead
 - include stack trace if there’s a crash and screenshots of the relevant code

  62. Asking for help The key to accelerate learning is by

    leveraging support It’s not worth being stuck for more than an hour: ask your classmates or post for help Help people help you: Don’t say ‘My app doesn’t work’
 - specific explanation of what you are trying to do and what happened instead
 - include stack trace if there’s a crash and screenshots of the relevant code
 - knowing how and when to ask for help is a vital skill not just in school, but also in the workplace
  63. Example: We are working on our ToDo app and we

    want to add the feature to edit a task, but once we click on an item to edit it, our app crashes Asking for help
  64. Example: We are working on our ToDo app and we

    want to add the feature to edit a task, but once we click on an item to edit it, our app crashes Bad way to ask for help: “My app is crashing”
 (we have no context and no idea how to help) Asking for help
  65. Example: We are working on our ToDo app and we

    want to add the feature to edit a task, but once we click on an item to edit it, our app crashes Bad way to ask for help #2: “My app is crashing when I click on an item to edit it”
 (we have no idea why it may be crashing) Asking for help
  66. Example: We are working on our ToDo app and we

    want to add the feature to edit a task, but once we click on an item to edit it, our app crashes Okay way to ask for help: “My app is crashing when I click on an item to edit it. I’m not sure why but here’s a stack trace:” Asking for help
  67. Example: We are working on our ToDo app and we

    want to add the feature to edit a task, but once we click on an item to edit it, our app crashes Best way to ask for help: “My app is crashing when I click on an item to edit it. I’m not sure why but here’s a stack trace and my code” Asking for help
  68. Example 2: We are working on our ToDo app and

    we want to add the feature to edit a task, and now we have everything set up, but when we go back to our MainActivity, the edit is not there Asking for help
  69. Example 2: We are working on our ToDo app and

    we want to add the feature to edit a task, and now we have everything set up, but when we go back to our MainActivity, the edit is not there Bad way to ask for help: “My app doesn’t work”
 (it doesn’t tell us in what way it doesn’t work) Asking for help
  70. Example 2: We are working on our ToDo app and

    we want to add the feature to edit a task, and now we have everything set up, but when we go back to our MainActivity, the edit is not there Bad way to ask for help #2: “My app doesn’t edit a task correctly”
 (it doesn’t give any context about what you’ve tried or how you’ve implemented the feature, so we have no idea what may have went wrong) Asking for help
  71. Example 2: We are working on our ToDo app and

    we want to add the feature to edit a task, and now we have everything set up, but when we go back to our MainActivity, the edit is not there Bad way to ask for help #3: “My app doesn’t edit a task correctly, and here’s what I have so far (attached screenshot)”
 
 
 (without seeing the other code in EditItemActivity, it’s hard to see what may have went wrong) Asking for help
  72. Example: We are working on our ToDo app and we

    want to add the feature to edit a task, but once we click on an item to edit it, our app crashes Good way to ask for help: “My app doesn’t edit a task correctly, and here’s what I have so far (attached screenshots of relevant code)”
 Asking for help
  73. Example: We are working on our ToDo app and we

    want to add the feature to edit a task, but once we click on an item to edit it, our app crashes Good way to ask for help #2: “My app doesn’t edit a task correctly, and I’m not sure what’s wrong, but here’s the link to my repo:
 https://github.com/calren/ToDoAppDemo
 Asking for help
  74. Keys to Success 1) Learn how to debug code 2)

    Understand the code you write 2) Ask for help 3) Be familiar with Android Studio
  75. Android Studio Tip #1 : Be able to know whether

    your app was successfully ‘deployed’
  76. Android Studio Tip #1 : Be able to know whether

    your app was successfully ‘deployed’ This means your app is still in the process of being built
  77. Android Studio Tip #2 : Know how to diagnose build

    errors
  78. Android Studio This means the app did not successfully build,

    and there’s an error in EditItemActivity. Specifically with an unrecognized `etNewIte` variable
  79. Android Studio This means in activity_main.xml, there’s a line android:ID,

    and Android Studio doesn’t understand what “ID” is (because it’s case 
 sensitive so it’s supposed to be “id”)
  80. Android Studio Tip #3 : Be familiar with LogCat

  81. Android Studio Tip #3 : Be familiar with LogCat Trash

    icon is useful to delete old log messages
 on every new app relaunch
  82. Android Studio Tip #3 : Be familiar with LogCat Filter

    to see error messages just from your app
  83. Android Studio Tip #3 : Be familiar with LogCat You

    can also filter for ‘types’ of messages
  84. Android Studio Tip #3 : Be familiar with LogCat Search

    bar lets you search for specific words
 like tags (Log.i(“Help”, “is button click processed?”))
  85. Android Studio Tip #4 : Sometimes, when strange errors appear

    out of nowhere, it’s not your fault at all
  86. Android Studio Tip #4 : Sometimes, when strange errors appear

    out of nowhere, it’s not your fault at all • restart emulator • Build -> Clean project • File -> Invalidate Caches and Restart • create new emulator instance (Tools -> AVD Manager -> Create
 
 Virtual Device)
  87. Android Studio Tip #5 : Utilize autocomplete

  88. Android Studio Tip #5 : Utilize autocomplete • Typing out

    things by hand can be very error prone
  89. Android Studio Tip #5 : Utilize autocomplete • Typing out

    things by hand can be very error prone
  90. Android Studio Tip #5 : Utilize autocomplete • Typing out

    things by hand can be very error prone • You can learn a lot about what’s available from autocomplete suggestions
  91. Android Studio Tip #5 : Utilize autocomplete • Typing out

    things by hand can be very error prone • You can learn a lot about what’s available from autocomplete suggestions
  92. Android Studio Tip #6 : Handy shortcuts

  93. Android Studio Tip #6 : Handy shortcuts • search for

    file 
 (Cmd + Shift + O for Mac and Control + Shift + N for Windows)
  94. Android Studio Tip #7 : Auto import classes

  95. Android Studio Tip #7 : Auto import classes

  96. Android Studio Tip #7 : Auto import classes Android Studio

    -> Preferences