So here as you can see I the access modifier of my my if it is public this method is static.
OK.
And the return type of this method is void and the name of my method is to verify that we can call someone
and this this it actually accepts an argument of type activity.
So here inside the Smurfit as you can see I have these lines of code.
And first of all in line 20 as you can see here I have a variable of type integer and the name of this
roundtable is permission.
So here I actually referred to the name of this activity compact class activity compact that check self
permission.
Ok here I want to check whether I can access the call feature of the device or not check self permission
and this method actually to accept two arguments.
The first one is the activity that we have as an argument of our Meffert.
And the second one is the permission that we are able to access manifest that permission the Khalfan.
OK.
And here I have an if statement.
As you can see here.
So if permission is not equal to package manager that permission granted.
Ok so if we don't have the permission that the user would allow me to do that.
OK.
So if the user wouldn't allow me to access the call feature of the device.
OK so this is the meaning of this piece of code here.
If permission is not equal to package manager that permission granted.
If we don't have access to that permission OK if the user wouldn't allow me to actually use the call
feature of the device.
And as you can see here I created the comment here.
We don't have the permission to so prompt the user.
So now I'm on to ask the user.
OK.
I want to ask the user to allow me to access the call feature of the device.
OK.
Activity compact that requires the permissions.
So if it actually accepts free arguments the first one is the activity the second one is the permissions
Aure that we want to actually ask the user.
So here is the permissions Aure.
And the first one is the request code.
So I have this request called call here.
OK.
Now here inside our uncreate Smurfette I want to actually call the Smurfette verify that we can call
someone.
So here I can't just type in verify that they can call someone.
And for the activity I can just type in here main activity that's this.
OK so now let's actually run our project and see what happens.
So now as you can see our application is running on this emulator here and here you can see now it is
asking me that this allow app 45 to make and manage phone calls.
So it is asking the user do you want to allow this application to make and manage phone calls.
If I hit on allow here OK I can actually call someone if I hit on the night here I would not be able
to call someone.
So here I can actually select this allow here and now I can call someone in my application.
So let's actually go back to my main activity here and it's actually at some more lines of code here
because at the moment our application wouldn't do so much in here because if I click on these buttons
here now you can see that we cannot actually do anything here.
So we need to put those logic's inside our main activity class.
So now I'm going to pasting some lines of code here and then I'm going to explain to you what's going
on here.
So as you can see here these are the lines of code that they actually place that inside this main activity
class.
OK.
So first of all I actually declared the spot in BT and would give me bt between our search Google BT
and Karl and Pythian access DeLaet.
So inside these uncreate Mefford after this line of code here verified that they can't call someone
here Ivonne to instantiate these but that I declared inside the main activity class.
So here I can just typing PTEN or Penni you the assignment operator and here I can just actually pass
this object to on to the button object find view by ID or that Id that PTEN open you the semicolon between
search Google assignment operator here.
I just need to cast this object to a button object find view by ID or that Id dot between Google search
search Google semi-colon and are here.
I just need to type in PTEN Col assignment operator Potin find.
View by id artist Id dot PTEN Col semicolon between Access Dyott had assignment operator and here I
need to cast this object to a button object find view by id r that ID that Pythian access dial pad semicolon.
OK so now here I want to actually make these buttons a listener to the clicks of the user.
OK so that our application would respond if the user touches one of these buttons.
So here I can just type in between.
Open you the me that set on click listener and here I need to pass the context main activity that this.
OK so this is our context.
And again I have this beauty and search Google so I can't just typing Pythia and search Google.
That said Anchal listener.
OK.
Main activity that this and here again we have this beauty and called PTEN Karl data set on calculus
and our main activity thought this here again we have this BT an Access style pad between access dial
pad that said on click listener main activity that is OK.
So here as you can see we have some errors and that's because of this interface we need to actually
implement the unclick list in an interface.
So here I can just typing after this compact activity here.
I can't just type in implements view thoughts on click listener.
So now again we have an error so we need to actually implement the uncle Smurfette in our main activity
class.
So here I can't just typing on Cliq and as you can see here is showing us this method here so I can
just press enter key here and now we have this method here public Voyt and click method.
So here as you can see if you have an argument of type view so the name of this argument is not good
here.
So I can't just change it to view.
OK so here because I want to differentiate between clicking of these buttons here I just need to create
a switch statement and I want to switch between the IDs of these buttons.
So here I can just type in view that gets ID.
OK.
And then I need to actually open and close this switch statement.
So here I can just type in our thought Id dot between open you'd see me.
So if the user clicks or touches that BT and the button here I have this logic here.
So here I actually forgot to put the case statement here.
Case r that ID that Pythian open Eudemus So if the user clicks on a BT and open you me then it's going
to respond.
We have other cases too.
So case are thought Id that Google search BT and search Google.
OK colon break.
And we have another case case are that Id dot PTEN.
Carl Sullivan here as you can see Colan break case Artaud already thought between access they L-pad
colon break.
So here I want to put the logic here for these patents.
So for this are BT and open to me here I want to paste in some lines of code here and then I'm going
to explain to you what's going on here.
So as you can see here these are the lines of code that I actually pasted here.
First of all I created an object of type intent and the name of this object is intent.
And here I put an assignment operator.
So here I want to instantiate this intent object new intent and inside the prentices I want to specify
that what that what would I want to do with this intent.
So I want this intense tragedy open of a browser and then go straight ahead to Eudemus dot com.
OK.
So in order to do that job I need to actually call this intent that action view OK I want to actually
open up a website in a web browser in my device.
So I need to call this intent that action view.
And here in the second line in line 81 as you can see we have this intent object that said data.
So here I want to I need to actually specify the data.
OK.
You are.
OK.
I call this you or I class that parse.
Hush TTP dot hostilely colon slash slash.
W w w dot you see me dot com.
OK.
And here as you can see I call this Meffert start activity intent.
So it's actually on our project and see what happens.
So now as you can see our application is running on this emulator here.
So if I actually click on this button here let's open you with me that's come let's see what happens.
And as you can see it's now opening to you to me datacom for me.
OK.
In my web browser.
So he had to be 10 cities Eudemus dot com.
OK.
So hopefully that makes sense.
So let's us actually click on the back button here.
Now I want to actually search the Google.
So let's actually put that logic here.
In this case statement here between search Google.
So here I am able to actually paste in some lines of code.
So as you can see here these are the lines of code that I actually paste that here.
First of all again I actually created an object of type intent and the name of this object is intent
to assignment operator.
So here I am instantiating this intent object and inside the prentices because I want to actually search
the verb.
I actually called intent that action a web search.
OK.
And here I have this intent to object that set data.
You are right that parse.
And instead of double quotes I just typed in hushed ETP colon slash slash.
W w w dot Google dot com.
OK.
And here I call this my first start activity intent too.
So let's run our project and see what happens.
So now as you can see our application is running Andi's emulator.
OK.
And here as you can see I want to actually click on this.
Let's search the Google.
And now as you can see it opened the website and now I can actually search the google here.
OK.
As you can see here.
So hopefully that makes sense.
So let me actually click on dispatch button here and here I want to call someone.
Ok this is very important.
So let's actually go back to our main activity class and put that logic here end card.
So here I'm going to paste in some lines of code and then I'm going to explain to you what's going on
here.
So as you can see here these are the lines of code that I actually paste that here and here as you can
see I created an if statement if context compact.
OK.
That takes self permission.
OK.
Because I want to actually call someone we need to first ask the user of whether they would allow me
whether they would allow the application or to call someone or not.
OK.
If context compact that check self permission.
So here we need to actually for the first argument Vini to specify this the context.
So I could just type in main activity that is OK for this and here for the sake of argument we need
to specify the permission that we want to actually access.
OK manifest that permission does Carl form.
OK.
As you can see here manifest that permission that Khalfan.
So if this permission is not equal to package manager that permission granted OK.
If the user if the user didn't allow me to access the Khalfan feature of my device of their device OK.
If my application is not allowed to access the call a feature of the device.
OK.
If the user didn't allow me to access the card feature here I want to ask them again activity compacts
that request permissions first.
Again I any to specify the context for here instead of this I could just type in main activity that
this and for the second argument we need to specify the permissions.
News strange.
And here as you can see I have an array of type strange object as you can see I created an array of
string object and inside that array I have this value manifest that permission that Khalfan and for
the first argument we need to specify the request code card.
As you can see here.
So here I actually ask the user whether they would allow me to access the call feature of the device
or not.
OK.
If they would allow me then I am allowed to actually access that feature.
So here I have an else statement.
If so if the user doesn't allow me to access the call feature OK then it's going to actually execute
this line of code here.
But if I have permission to access the call feature then it's going to execute this else statement.
OK.
Intent intent free Neil intent intent that action card.
OK.
So here this is the action card.
And here again I referred to the name of this object intent free that said they tell you outright that
parts and inside the double quotes.
I just need to specify the number that you want to call.
OK the phone number that I want to call.
So here I just need to put this tell here tell call in.
So this is an important Tell call in.
And here it is going to be the phone number that you want to call.
And here as you can see I call this my fifth start activity intensively.
So let's run our project and see what happens.
So here as you can see our application is running on this emulator here.
So now I want to actually call someone let's So here let's actually click on this button here.
Let's call someone.
And now as you can see I am calling someone with this number.
OK.
So hopefully that makes sense.
And let's actually click on this back button here.
So now I want to access the dial pad.
OK.
So let's actually go back to our main activity the java file here and let's actually put that logic
here bt an access dial pad.
So here I'm going on pasting some lines of code and then I'm going to explain to you what's going on
here.
So as you can see here these are the two lines of code that they actually paste that here.
So here I created an object of type intent and the name of this intent is our intent for this intent
object assignment operator.
So here I actually instantiated this object new intent and in say The Apprentice's I specified that
I want to access the actual Dayal.
OK.
Intent that action.
Daniel and here I call the Smurfette starved activity intent forth.
So now let's actually run our project and see what happens.
So as you can see here now our application is running on this simulator here.
Let's access that dial pad.
So let's actually click on this button here and now as you can see I can actually access the dial pad
here.
OK.
So here if I actually click on the spot in here now I can access the dial pad or do something else.
As you can see here and call someone.
OK.
So hopefully that makes sense and I think that's enough for this tutorial.
So if you have any questions please post the discussion in the course and then I'll do my best to answer
all of your questions.
Thank you very much for watching and I'll see you in the next year Tauriel.