So i’m trying to understand all the code from the NotePad sample, but i’m having some difficulties :
first, how to tell that our project starts from the “X” file ? like an “index” file..?
(i guess it’s starting from the NoteList page) In this NoteList page, we get the current intent with getIntent(), then the data from it : but :
- which activity started the note list? (i think none, and all the activities in this project have this getIntent() method, so is there an intent “sent” automatically when a project is launched?)
- we set the data to the new intent variable, but we then pull the data in the cursor like this :
getIntent().getData(): is it passed by “reference” or something like that? so that using the new intent variable or getIntent() is the same?
Thanks for your help 😉
>
// Gets the intent that started this Activity.
Intent intent = getIntent();
// If there is no data associated with the Intent, sets the data to the default URI, which
// accesses a list of notes.
if (intent.getData() == null) {
intent.setData(NotePad.Notes.CONTENT_URI);
}
/*
* Sets the callback for context menu activation for the ListView. The listener is set
* to be this Activity. The effect is that context menus are enabled for items in the
* ListView, and the context menu is handled by a method in NotesList.
*/
getListView().setOnCreateContextMenuListener(this);
/* Performs a managed query. The Activity handles closing and requerying the cursor
* when needed.
*
* Please see the introductory note about performing provider operations on the UI thread.
*/
Cursor cursor = managedQuery(
getIntent().getData(), // Use the default content URI for the provider.
PROJECTION, // Return the note ID and title for each note.
null, // No where clause, return all records.
null, // No where clause, therefore no where column values.
NotePad.Notes.DEFAULT_SORT_ORDER // Use the default sort order.
);
NoteList is the main entry point of the App. Refer to the AndroidManifest.xml to see the Launcher and Main intent filters
Each Activity is started by an Intent. getIntent() call in a Activity. This call returns the Intent object which started it. In notepad NoteID -(which is a URI) is passed from one activity to as a parameter in the Intent object.