Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###### java code Bedroom 2 AC
- package com.example.shikhadwivedi.homeautomation;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.Button;
- import android.widget.CompoundButton;
- import android.widget.ToggleButton;
- /**
- * Created by root on 13/6/18.
- */
- public class Room2Ac extends AppCompatActivity {
- ToggleButton room1,living,room2;
- Button read;
- Thread thread ;
- Intent intent;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.room2ac);
- read = (Button) findViewById(R.id.acreadings);
- read.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(new Intent(Room2Ac.this,Readings.class));
- }
- });
- room2 = (ToggleButton) findViewById(R.id.room2act);
- room2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked){
- Url_run xyz = new Url_run("http://192.168.0.15/br2_acon");
- thread = new Thread(xyz);
- thread.start();
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.15/br2_acon"));
- }
- else{
- Url_run xyz = new Url_run("http://192.168.0.15/br2_acoff");
- thread = new Thread(xyz);
- thread.start();
- Intent intent1=new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.15/br2_acoff"));
- }
- }
- });
- }
- }
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- ###### xml code of Bedroom 2 AC
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bedroom1"
- android:orientation="vertical"
- >
- <LinearLayout
- android:id="@+id/roomac"
- android:layout_width="match_parent"
- android:layout_height="100sp"
- android:layout_margin="20sp"
- android:background="@drawable/headings"
- android:gravity="center">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="AC Status"
- android:textColor="#ffffff"
- android:textSize="35sp" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="70sp"
- android:layout_margin="20sp"
- android:gravity="center"
- >
- <Button
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:text="Readings"
- android:textSize="30sp"
- android:textColor="#3c0660"
- android:background="@drawable/oval"
- android:id="@+id/acreadings"/>
- </LinearLayout>
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="70sp"
- android:layout_margin="20sp"
- android:background="@drawable/oval"
- android:orientation="horizontal">
- <TextView
- android:id="@+id/actext"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginLeft="10sp"
- android:gravity="left"
- android:text=" AC"
- android:textColor="#3c0660"
- android:textSize="30sp"
- android:drawableLeft="@drawable/ac"
- android:padding="10sp"
- />
- <ToggleButton
- android:id="@+id/room2act"
- android:layout_width="60sp"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_marginRight="30sp"
- android:layout_marginTop="10sp"
- android:background="@drawable/headings"
- android:textColor="#ffffff"
- android:textSize="20sp"
- android:fontFamily="cursive"
- android:layout_marginBottom="10sp"/>
- </RelativeLayout>
- </LinearLayout>
Add Comment
Please, Sign In to add comment