I am just starting to develop Android (being a .Net developer)
I am following the code from a book, and to start a new 'form' (screen) they show this code
Intent i = new Intent("net.learn2develop.ACTIVITY2");
The class definition is this:
package net.learn2develop.Activities;
//imports removed
public class Activity2 extends Activity {
My question is: i presume that the string in the constructor in the Intent is the classname.
But why is it 'net.learn2develop'
and not 'net.learn2develop.Activities'
and why is the classname all caps?
Take a look at documentation: Intent(String action).
So this is actually action name, not class name. They usually look very similar to unprepared eye. Take a look at
AndroidManifest.xml
and search fornet.learn2develop.ACTIVITY2
string. You should find somehting like:No need to use the class name as caps. In fact use it exactly the way you have declared it . As android uses java as language and java is a case sensitive language.
For example to start the new acivity:
or
Finally dont forget to declare the new Activity in manifest file.