Skip to content Skip to sidebar Skip to footer

Intent Constructor Syntax

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('ne

Solution 1:

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 for net.learn2develop.ACTIVITY2 string. You should find somehting like:

<activityandroid:name=".Activity2" ><intent-filter ><actionandroid:name="android.intent.action.ACTIVITY2" /><categoryandroid:name="android.intent.category.DEFAULT" /></intent-filter></activity>

Solution 2:

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:

Intent i=newIntnet("net.learn2develop.Activity2"); //assuming that your package name is net.learn2developstartActivity(i);

or

Intent i=newIntnet(Activity1.this,Activity2.class) //assuming that your current class name is Actvity1 startActivity(i);

Finally dont forget to declare the new Activity in manifest file.

Post a Comment for "Intent Constructor Syntax"