0% found this document useful (0 votes)
15 views9 pages

Screenshot 20240508-111301 2

Ft j kg

Uploaded by

kartikukey04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
15 views9 pages

Screenshot 20240508-111301 2

Ft j kg

Uploaded by

kartikukey04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 9
8) Set OnZeombut UleK Litt hes (onticxListeucilistier) Te palit hen eel OF pein et boven pene )setIstoamntveblea( boot i tanbled):-thu meited 12 cud Jo cunuie ov Atsabie in eta, aan MH wecHlod we det a Beotean mtettrod IsZoomOu tuadted [ U tabled): Thu mettiod is wed to enable on Aue Koomoutr of istView android:id="@ 4id/11"/> JAVA FILE package com.example.exp29 import androids.appcompat.app.AppCompatActivity i import android.net.Uri: import android.os. Bundle: import android.widget. Array Adapter, import android.widget.ListVie import java.util ArrayList; public class MuinActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savednstanceState) { super.onCreate(savedInstanceState); setContentView(R layout.activity_main) ListView Il = findViewByld(R id.) ArrayList sms = new ArrayList(); Uri uriSms = Uri.parse(“content:/sms/inbox"); Cursor c = getContentResolver().query(uriSms, new String[]{"_id", "address","body"}, null,null, null); emoveT First): while (c:moveToNext() [ String address = e.getString(1); String body = c.getString(2); sms.add("\nSMS FROM: * + address." } ArrayAdapter adapter = new ArrayAdapter(this, android. layout.simple_list_item_1, sms); 11 setAdapter(adapter) } ) ANDROIDMANIFEST:XML port android. database.Cursor: SMS = ;" + body); a2|Page Q.6) Attempt any TWO of the followin; (12 Marks) a) 16h 2 Develop an application to store student details like roll no, name, branch, marks percentage and retrieve student information using roll no. in SQLite databases. ANS- JAVA FILE Public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Initializing controls editRolIno=(EditText)find ViewByld(R .id.editRolino); editName=(EditText)find ViewByld(R .id.editName): ceditMarks=(EditText)find ViewByld(R .id.editMarks); binAdd=(Button)find ViewByld(R .id.binAdd); binViewAll=(Button)find ViewByld(R.id.btnViewAll); Registering event handlers, btnAdd.setOnClickListenertthis); binViewAlll setOnClickListener(this) Creating database and table db=openOrCreateDatabase("StudentDB”, Context. MODE_PRIVATE, null); db.exeeSQL("CREATE TABLE IF NOT EXISTS student(rolino VARCHAR,name VARCHAR, marks VARCHAR)’ } public void onClick(View view) { ‘Adding a record binAdd) iftvie { Checking empty fields iffeditRollno .getText(,toString().trim().length editName.getText() toString().trim() length()==0) h()==0) editMarks. getText() toString().trim() len { showMessage("Erro”, "Please enter all values"); return; ) Viewing all records iffview==btnViewAll) ( Retrieving all records b) 17|Pae Cursor c=db.rawQuery("SELECT * FROM stud Checking if no records found if(.getCount0 { showMessage("Error" "No records found"); return; ) // Appending records to a string buffer StringBuffer buffer-new StringBuffer(); while(c.moveToNext()) { buffer-append("Rollno: "+<.getString(0)+"\n") buffer.append("Name: "+c.getString(1)+"\n"); buffer.append( "Marks: c.getString(2)+"\n\n" } Displaying all records showMess: Vy) Write a program to locate user's current location. (Write ONLY java and manifest file) ANS- JAVA FILE package com.example.exp31 import androidx.core.app.ActivityCompat; import androids. fragment.app.FragmentActivity; import android. Manifest; nport android content. pin. PackageManager; nport android. location, Locatio nport android location.Locationl import android Jocation.LocationManager import android.os. Bundle; import com.google.android. gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android. gms.maps. OnMapReadyCallback; nport com.google.android.gms.maps. Support MapFragment: nport com,google.android.gms.maps.model. LatLng; nport com google.android.gms.maps.model. MarkerOptions; import com.example.exp31_databinding. Activity MapsBinding; public class MapsActivity extends FragmentActivity implements ‘OnMapReadyCallback { private GoogleMap mMap; private LocationManager locaMan; private LocationL istener locat; private final long MIN_TIME = 1000; private final long MIN_DIST = 5 tudent Details”, buffer.toString()): private LatLng latLng: private ActivityMapsBinding binding; @Override protected void onCreate(Bundle savedInstanceSts super.onCreate(savedInstanceState); binding = ActivityMapsBinding inflate(getlayoutInflater()); setContentView(binding. getRoot()); ‘SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() findFragmentB yld(R.id.map); mapFragment.getMapAsyne(this): ActivityCompat.requestPermissions(this, new String{]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest permission.ACCESS_COARSE_LOCATION}, Package Manager. PERMISSION_GRANTED); A y{ tyCompat.requestPermissions(this, new String{]{Manifest.permission INTERNET}, PackageManager PERMISSION_GRANTED); latLng = new LatLng(-34, 151); } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap: locat = new LocationListener(){ @Override public void onLocationChanged(Location location) {wry { JatLng = new LatLng(location.getL atitude(), location.getLongitude()); mMap.addMarker(new MarkerOptions() position(latL ng) title(”My Position")); mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); } catch (Exception e){ e.printStackTrace(); ) ) @Override public void onStatu Bundle extras) { } @Override public ve } @Override public void onProviderDisabled(String provider) { Vhs locaMan = (LocationManager) getSystemService(LOCATION_SERVICE); try “hanged (String provider, int status, onProviderEnabled(String provider) { 18 [Pare °) as} locaMan.requestl.ocationUpdates(Location Manager NETWORK_PROVIDER, MIN_TIME,MIN_DIST,locat); locaMan request ocationUpdates(LocationManager.GPS_PROVIDER .MIN_TIME.MIN_DIST,locat); } catch (SecurityException e){ e-printStackTrace(); } double lati = latL ng. latitude; double longi = latLng.longitude; latLng = new LatLng(lati, longi): mMap.addMarker(new MarkerOptions(),position(latLng).title(”Current Lo mMap.moveCamera(C ) 1 ANDROIDMANIF Develop a simple calculator using table layout. AN XML FILE- sation”) neralpdateFactory.newLatLng(latL.ng)): 2ST.XML: android:nam