0% found this document useful (0 votes)
63 views6 pages

Mobile App Development Exercise 22

The document contains details of a student named Ekambe Ganesh Dattatraya including their roll number 53. It describes two practical exercises involving Android activities and layouts. The first practical sets the background color of a constraint layout based on device orientation. The second retrieves a list of all sensors on the device and displays it in a list view.

Uploaded by

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

Mobile App Development Exercise 22

The document contains details of a student named Ekambe Ganesh Dattatraya including their roll number 53. It describes two practical exercises involving Android activities and layouts. The first practical sets the background color of a constraint layout based on device orientation. The second retrieves a list of all sensors on the device and displays it in a list view.

Uploaded by

Ganesh Ekambe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: Ekambe Ganesh Dattatraya

Roll No. :53

Practical No. : 22

Exercise

Ans 1)

activity_main.xml

<?xml version=”1.0” encoding=”utf-8”?>


<[Link]
xmlns:android=”[Link]
oid” xmlns:app=”[Link]
auto” xmlns:tools=”[Link]
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:id=”@+id/Layout”
tools:context=”.MainActivity”>

[Link]
package [Link].exp22;
import [Link];
import
[Link];
import [Link];
import
[Link];
import [Link];
public class MainActivity extends AppCompatActivity
{ConstraintLayout
constraintLayout; @Override
protected void onCreate(Bundle savedInstanceState)
{[Link](savedInstanceState);
setContentView([Link].activity_main);
constraintLayout =
findViewById([Link]);
if(getResources().getConfiguration().orientatio
n ==
Configuration.ORIENTATION_PORTRAIT){
[Link]( [Link](“#2cbdf2”));
}

if(getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE){
[Link]([Link] Color”#f083f2”));
}}}
Ans 4)
actvity_main.xml

<?xml version=”1.0” encoding=”utf-8”?>


<[Link]
xmlns:android=”[Link]
oid” xmlns:app=”[Link]
auto” xmlns:tools=”[Link]
android:layout_width=”match_parent”
android:layout_height=”match_parent”
tools:context=”.MainActivity”>
<ListView
android:id=”@+id/listView1”
android:layout_width=”match_pare
nt”
android:layout_height=”match_parent” />
</[Link]>

[Link]

package [Link].exp22_1;
import [Link];
import
[Link];
import [Link];
import [Link];
import
[Link];
import [Link];
import [Link];
import
[Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity
{SensorManager
smm; List<Sensor>
sensor; ListView lv;
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState)
{[Link](savedInstanceState);
setContentView([Link].activity_main);
smm = (SensorManager)
getSystemService(Context.SENSOR_SERVICE); lv = (ListView)
findViewById ([Link].listView1);

sensor = [Link](Sensor.TYPE_ALL);
[Link](new
ArrayAdapter<Sensor>(this,[Link].simple_list_item_1, sensor));
}

Output
Mobile Application Development(22617)

You might also like