Well, you've got several questions here.
Why it's necessary to declare a Button (gpsButton) and where/how I can create it?
If you want to create a button then you can declare it in either in the XML layout used by your Activity or else you can add it in code. If you're simply pasting the code from some sample, you'll need to understand that this code actually creates a reference to a Button object by finding it in the current view hiearchy (meaning the layout currently being displayed) by it's id. So if you haven't created a button with id of buttonGPSLocation somewhere in XML, then this code won't work. As to why it's necessary: it seems like the author of the sample decided to prompt the user to tap a button in order to open the phone setting and enable GPS.
The code can be overall putted after the class MapActivity or must be putted after the first onCreate?
This question isn't very clear (might be a language issue here), but it might help if you post all the relevant code. In general, setting onClickListeners should probably be done in onCreate of your Activity. Whether it's done inside of a MapActivity or not depends on more information that you haven't supplied to us.
What is OUTERCLASS?
In Java, you can define a class inside of another class. We usually see classes defined as "top level" classes, i.e. some file names SomeClass.java, the contents of which look like
public class SomeClass {
//some code
}
Now, when you define a class inside of another class, the "nested" one is the inside of the other and not vice versa. So the one that contains the nested class is the "outer" class.
class OuterClass {
...
class NestedClass {
...
}
}
Why does this all matter? Well because there are some rules about how things work between outer and nested classes. In your case what's most relevant is the fact when you set an onClickListener on an button, what you're actually doing is passing a reference to an instance of the OnClickListener class. In Java, you can create an anonymous inner class, which means that instead of defining some top level class that implements onClickListener (which btw, you can easily by having the class that all of this is happening in simply declare that it implements the onClickListener interface, e.g. public class WhateverMyClassNameIs extends Activity implements View.OnClickListener
) you are actually just creating an unnamed, on the fly onClickListener instance which cannot be referenced anywhere else because you haven't declared a reference to it. Now, the issue is that inside of this onClicklistener instance, when you want to now refer to the outer class that it's defined in (in your case, the Activity class), you cannot just use "this" anymore since "this" is actually the onClickListener because of the way that "scope" works. In other words, an OnClickListener has no method called "startActivity"; only an Activity class does (or your class that extends Activity). So you have to use what's called the "qualified this" to clarify that you intend to reference the "outer class", which is why you need *MyActivity*.this.startActivity...
A part of the permission on Manifest(I already have) I've to change
something on Layout?
The manifest and layout files are two totally different things. They are both defined using XML, but they're totally different. The manifest, among other things, contains a declaration of all of your Activity classes and permissions that the app is requesting, etc. Layout files are the actual layouts used inside of Activities (the UI). They should be located in res/layout and you can define whatever you want there. When you need to then make that UI "alive" you have to grab references to your widgets (buttons, textviews) etc inside of your Activity in code and then do what you want there.