Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Havigatbon PP

activity, mainzm MainActivityjava

K<?xnl version=1.0h encoding="utf-8"?> O1 A9 A1

F<LinearLayout xnlns: android="http://schemas.android. con/apk/ res/android"


Xnlns:appa"http://schenas. android. com/apk/res-auto"
XmLns:to0ls=" http://schemas, android. con/tools"
android:layout_width"natch_parent"
android:layout_height"natch_parent"
tools:context=".MainActivity"
android:orientation="vertical" >
<EditText
android:layout_Width="rap_content"
android:layout_height="nrap_content"
android:1d="9+1d/et_ source"
13 android:hint"Enter Source Lacation"

<EditText
android:layout_Width="rap_content"
12 android:ayout_height="wrap_content
android:id="0+id/et_dest"
10 android:hínt-"Enter Destination Locationt

<Button
android:layout_width="urap_content"
android:layout_height="wrap_content" T
android:id="0+1d/bi"
android:text="Uisplay Location />

/LinearLayout>

LinearLayout EditTet
PV
Version Contral
ETODOProblems Terminal App Quality Insights O Senites ADp inspection
Eile Edit View Navigate Code Befactor
com) example navigation) MainActivity
Resource
Manager
ProjedNavigation) apPP src main java
sctivity_main.xm! x MainActivityjava
package com. example. navigation;
CompatActivity;
Oimport androidx .appcompat. app. App

import android. annotation. SuppressLint;


import android. content . ActivityNotFoundException;
7 import android. content . Intent;
import android. net . Uri;
import android. os . Bundle;
10 import android. view. View;
11 import android.widget. Button;
12 import android. widget. EditText;
13 import android . widget.Toast;
14
15
16 public class MainActivity extends AppCompatActivíty {
17
2 usages I
18 EditText etsource, etdestination;
Strudure 2 usages
19 Button bi;
20 OSuppressLint ("MissingInflatedId")
21 G0verride
22 protected void onCreate (Bundle savedInstancestate) {
23 super. onCreate (savedInstanceState);
24 setContentVíew(R. Layout. octivity_main) ;
25
26 etsource= (EditText) findVíewById (R.id. et_soUrce);
27
etdestination= (EdítText) findviewById (R.id. et_des t);
22 bl= (Button) findVíewById (R.id.b1) ;
29 b1.setonCLíckLístener (new View. OnCLíckListener O {
30 GOverride
public void onCLíck (Víew v) {
y Version Controt TODO Problems Terminal App Quality Insights O Sen
Micosot Defende configuration: The IDE has detected Microsoft Defender with Real-Tirme Protection
package com.exXample.navigation;

Hinport . .

15
16 public class MainActivity extends AppCompatActivity {
17

2 usages
18 EditText etsource, etdestination;
2usages
19 Button bl;
20 @SuppressLint ("MissingInflatedId")
21 G0verride
22 ef b protected void onCreate (Bundle savedInstanceState) {
23
Super.onCreate (savedInstanceState):
setContentView (R.Layout.activity_moin);
25
26 etsource=(EditText) findViewById (R.1d.et_source);
27
etdestination= (EditText) findViewById (R.id.et_dest) ;
28 bl=(Button) findViewById (R. 1d. b1);
29
bl.setonClickListener (new View.OnClickListener () {
30
B0verride
31 of public void onCLick(View v) {
32

33
String ssrcsetsource.getText (). toString (). trin();
34
String sdes=etdestination.getText () . toString ().trín();
35
if (ssrc. equals ("*)& sdes.equals ("") )
37
38
Toast.makeText( context MainActivity. this, tat "Enter Both Locations, Toast. LENGTH_SHOR).show(0:

1
elset
DisplayTrack (ssrc, sdes);
P Version Control TODO Problems Terminal App Quality fnsights O Services App InspectionELogcat
Microsoft Delender confiquratior The 1DE Profiler
atin) 2pp sc) main java) com) eample navigation)MainActivity)O onCreate) anonymous OnClickistener)onClick 5 sppCSmall Phone API 30 d B
Pactivity,mainxmxMeinActivity a

Toast.aokeText( contet MainActivity. this, tert "Enter Both Locations", Toast. LENGTH_SHORT) .shoN() ;

etsef
DisplayTrack(ssrc, sdes) ;

Tusage
47 private void Display Track (String ssrc, String sdes)
4 try {
Uri uri-Uri. porse ( unString
"https://qo0qle.co.in/naps/dir/"*ssrc+"/"*sdes);
Intent intent=new Intent (Intent. ACTION_VIEW, Ur1);

5 intent.setPackage("com.google.andro1d.apps.naps");
intent.setFlags (Intent.FLAG ACTIVITY NEW_TASK):
startActivity (intent):

catch (ActivityNotFoundException e){


Uri uri=Uri.parse ( unString
intent. "https:/ play.qooqle.con/store/apps/deta1ls?1d=cOn.q00qle.android,spps.maps");
Intent intent=nem Intent(Intent . ACTION_VIEW,
IE, Ur1);
setFlags (Intent. FLAG ACTIVITY_NEN_ TASK);
startActivity (intent);

P Vion Cortrl
ETODO Prselems Terminal
ooh Dlender configution App Cuality Insights O
The DE has deeced M Stnices App Inspection

You might also like