lock window using android

Server Side Code Using Java

LockWindow.java


package com.deep;

public class LockWindow {

     public void lockWindow(){
           try{
     Runtime rt = Runtime.getRuntime();
     Process pr = rt.exec("C:\\Windows\\System32\\rundll32.exe user32.dll,LockWorkStation");
           }catch (Exception e) {
                System.out.println(e);
           }
     }
}

index.jsp

<%@page import="com.deep.LockWindow"%>
<%
String lock=request.getParameter("lock");
    if(lock!=null){
    new LockWindow().lockWindow();
    out.print("Successfully Lock");
    }else{
    out.print("Lock Failed !");
    }
%>

Android Code

activity.xml

  <xml version="1.0" encoding="utf-8"?>
  <RelativeLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">


    <LinearLayout android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_centerInParent="true">

        <ImageView
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:id="@+id/imagedata"
            android:background="@drawable/unlock"
            android:layout_gravity="center"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:text="Deep Singh"
            android:typeface="serif"
            android:gravity="center"
            android:textStyle="bold"
            android:textColor="#000000"
            android:id="@+id/textdata"/>
    </LinearLayout>


</RelativeLayout>

MainActivity.java

package com.example.lockwindow;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import java.util.HashMap;
import java.util.Map;

public class MainActivity extends AppCompatActivity {


    ImageView im;
    TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        im=(ImageView)findViewById(R.id.imagedata);

        tv=(TextView)findViewById(R.id.textdata);

        im.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                sendToServer();

            }

        });

    }



    private void sendToServer(){

        StringRequest sr=new StringRequest(Request.Method.POST,

 "http://192.168.42.198:9876/LockWindow/", 


new Response.Listener() {


 @Override
 public void onResponse(String s) {

    if(!s.isEmpty()){

    im.setImageResource(R.drawable.lock);

    tv.setText(s);

}
            }
        },

 new Response.ErrorListener() {


 @Override
 public void onErrorResponse(VolleyError volleyError) {

                Toast.makeText(MainActivity.this,

          "Error : " + volleyError, Toast.LENGTH_SHORT).show();

            }

        }){
       

 @Override
 protected Map getParams() throws AuthFailureError {

            HashMap<String,String> h=new HashMap();

            h.put("lock","lock");

             return h;

            }

        };

        Volley.newRequestQueue(this).add(sr);

    }

}
  

11 comments:

John Smith said...

I in actuality value this blog to have such sort of instructive learning. Best responsive design website

TechMatrite said...

First of all, you have to choose an app then customize your content (text) of your choice and even pictures. Finally share it. Cyberflix TV

dk said...

The below appears prefer most likely awesome. Almost all these limited ideas are created with the use of range of facial foundation comprehension. I like these products somewhat. Development

Lifelink said...

When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. Atlanta Locksmith

Sam Baker said...

Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading
your blog more. You made a good point but I can't help but wonder, what about the other side?content://com.android.browser.home/

rthwer said...

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. Flir Cloud for PC

Sam Baker said...

This is such a great resource that you are providing and you give
it away for free.https://1asiaqq.net

tike mik said...

One of her issues though with technology is that she had come from Puerto Rico about a year prior entering college and that she never had to use the computer so much there. The articles relates that other college students like Nichole have admitted that they are "reluctant technology users" (Lohnes) The article wants to explain, in essence, that although most people would expect that college students prefer technology and are already familiar with it," that assumption is faulty" (Lohnes). open link

TechMatrite said...

This post is very simple to read and appreciate without leaving any details out. Great work! https://satta-king.center/

Anonymous said...

providing a good help with source free

Anonymous said...

it is valuable article give good information spotity