0% found this document useful (0 votes)
28 views3 pages

Wi-Fi Service Control App Code

The document contains an Android application layout and main activity code for managing a Wi-Fi service. It includes a simple user interface with two buttons to start and stop the Wi-Fi service. The MainActivity class handles the button click events to start and stop the service using intents.

Uploaded by

Vaman Kulkarni
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)
28 views3 pages

Wi-Fi Service Control App Code

The document contains an Android application layout and main activity code for managing a Wi-Fi service. It includes a simple user interface with two buttons to start and stop the Wi-Fi service. The MainActivity class handles the button click events to start and stop the service using intents.

Uploaded by

Vaman Kulkarni
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

Exp.

20

#activity_main.xml

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

<LinearLayout xmlns:android="[Link]

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:gravity="center"

android:padding="16dp">

<Button

android:id="@+id/startWifiButton"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Start Wi-Fi Service" />

<Button

android:id="@+id/stopWifiButton"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Stop Wi-Fi Service"

android:layout_marginTop="20dp" />

</LinearLayout>
#[Link]

package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends AppCompatActivity {

private Button startWifiButton, stopWifiButton;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_main);

startWifiButton = findViewById([Link]);

stopWifiButton = findViewById([Link]);

// Start the service to enable Wi-Fi

[Link](v -> {

Intent startServiceIntent = new Intent([Link], [Link]);

startService(startServiceIntent); // Start the service


});

// Stop the service and disable Wi-Fi

[Link](v -> {

Intent stopServiceIntent = new Intent([Link], [Link]);

stopService(stopServiceIntent); // Stop the service

});

You might also like