Android Small project where is you monitor

Source: Internet
Author: User

The first small project, the implementation of monitoring SMS, telephone, as well as ringing, vibration, monitoring location has not been added, will be updated later, first put the code up

The first one is a login interface:


Xml:


<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:id=" @+id/relativelayout1 "android:layout_width=" Match_parent "Android:backgrou nd= "@drawable/green1" android:layout_height= "match_parent" android:orientation= "vertical" android:paddingbottom= " @dimen/activity_vertical_margin "android:paddingleft=" @dimen/activity_horizontal_margin "android:paddingright=" @ Dimen/activity_horizontal_margin "android:paddingtop=" @dimen/activity_vertical_margin "tools:context=". Mainactivity "> <textview android:id=" @+id/textview1 "android:layout_width=" Wrap_content "an droid:layout_height= "Wrap_content" android:layout_alignparentleft= "true" android:layout_alignparenttop= "true        "Android:layout_marginleft=" 34DP "android:layout_margintop=" 40DP "android:textcolor=" #ff008000 " android:text= "User name:"/> <edittext android:id= "@+id/txtlogin" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:lay Out_alignparentleft= "true" android:layout_below= "@+id/textview1" android:layout_marginleft= "28DP" and roid:layout_margintop= "25DP" android:ems= "ten" > <requestfocus/> </EditText> <textvi EW android:id= "@+id/textview2" android:layout_width= "wrap_content" android:layout_height= "Wrap_conten T "android:textcolor=" #ff008000 "android:layout_alignleft=" @+id/txtlogin "android:layout_below=" @+id/ Txtlogin "android:layout_margintop=" 30DP "android:text=" Password: "/> <edittext android:id=" @+id/t Xtpass "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:layout_align left= "@+id/textview2" android:layout_centervertical= "true" android:ems= "android:inputtype=" TextPa ssWOrd "/> <button android:id= "@+id/btnlogin" android:layout_width= "100DP" android:layout_height= "50DP" Andro id:layout_alignleft= "@+id/textview1" android:layout_alignright= "@+id/txtlogin" android:layout_below= "@+id/tx        Tpass "android:layout_margintop=" 22DP "android:textcolor=" #ff008000 "android:background=" #5f888888 " android:text= "Login"/> <button android:id= "@+id/btnabout" android:layout_width= "100DP" a        ndroid:layout_height= "50DP" android:layout_alignleft= "@+id/btnexit" android:layout_alignparentbottom= "true"         Android:textcolor= "#ff008000" android:background= "#5f888888" android:layout_alignright= "@+id/btnexit"        android:text= "About Landing"/> <button android:id= "@+id/btnexit" android:layout_width= "100DP"        android:layout_height= "50DP" android:layout_alignleft= "@+id/btnlogin" android:textcolor= "#ff008000" Android:background= "#5f888888 "android:layout_alignright=" @+id/btnlogin "android:layout_below=" @+id/btnlogin "android:layout _margintop= "15DP" android:text= "Exit"/></relativelayout>

Mainactivity.java

Package Com.example.whereareyou;import Android.os.bundle;import Android.app.activity;import android.content.Intent ; Import Android.view.menu;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.edittext;import Android.widget.toast;public class MainActivity extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); final EditText txtlogin = (EditText) This.findviewbyid (R.id.txtlogin); final EditText Txtpass = (EditText) This.findviewbyid (R.id.txtpass); Button Btnlogin = (button) This.findviewbyid (R.id.btnlogin); Button Btnexit = (button) This.findviewbyid (r.id.btnexit); Button Btnabout = (button) This.findviewbyid (r.id.btnabout); Btnlogin.setonclicklistener (new Onclicklistener () {@        overridepublic void OnClick (View arg0) {//TODO auto-generated method stub Intent Intent = new Intent (); String login = Txtlogin.gettext (). ToString ();    String pass = Txtpass.gettext (). toString (); if (Login.equals ("Ahut") && pass.equals ("123")) {Toast.maketext (Getapplicationcontext (), "Welcome", "+"). Show ( ); Intent.setclass (Getapplicationcontext (), lmainactivity.class); startactivity (intent);} Else{toast.maketext (Getapplicationcontext (), "User name or password error", "N"). Show ();}}); Btnabout.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated Method Stubtoast.maketext (Getapplicationcontext (), "User name: Ahut Password: 123" + "@ Anhui University of Technology Computer College Sing", 8*1000). Show ();}); Btnexit.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated Method Stubsystem.exit (0);}}); @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is PR Esent.getmenuinflater (). Inflate (R.menu.lmain, menu); return true;}}

The second one is the monitoring page


Xml:



<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:id=" @+id/relativelayout2 "android:layout_width=" Match_parent "Android:layout_h eight= "Match_parent" android:background= "@drawable/green1" android:orientation= "vertical" android:paddingbottom= " @dimen/activity_vertical_margin "android:paddingleft=" @dimen/activity_horizontal_margin "android:paddingright=" @ Dimen/activity_horizontal_margin "android:paddingtop=" @dimen/activity_vertical_margin "tools:context=". Lmainactivity "> <edittext android:id=" @+id/txtnumber "android:layout_width=" Match_parent "a ndroid:layout_height= "Wrap_content" android:layout_alignparentleft= "true" android:layout_below= "@+id/textVie W1 "android:ems=" android:inputtype= "phone" > <requestfocus/> </EditText> &l T CheckBox android:id= "@+id/cbphone" Android:laYout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_alignparentleft= "true" android:layout_below= "@+id/txtnumber" android:text= "listening Phone" android:textcolor= "#ff008000"/> <checkbo        X android:id= "@+id/cbsms" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:layout_alignparentleft= "true" android:layout_below= "@+id/cbphone" android:text= "Listen SMS" a Ndroid:textcolor= "#ff008000"/> <checkbox android:id= "@+id/cbcall" android:layout_width= "Wrap_conte NT "android:layout_height=" Wrap_content "android:layout_alignparentleft=" true "android:layout_below=" @+id/cbsms "android:text=" callback Phone "android:textcolor=" #ff008000 "/> <checkbox android:id=" @+id/ Cbring "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:layout_align       Parentleft= "true" android:layout_below= "@+id/cbcall" android:text= "Ring" android:textcolor= "#ff008000"/> <checkbox        Android:id= "@+id/cbvib" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:layout_alignparentleft= "true" android:layout_below= "@+id/cbring" android:text= "Vibration" android:t        Extcolor= "#ff008000"/> <checkbox android:id= "@+id/cbloc" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_alignparentleft= "true" android:layout_below= "@+id/cbVi B "android:text=" Position monitoring "android:textcolor=" #ff008000 "/> <textview android:id=" @+id/textview1 "Android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:layout_alignparent Top= "true" android:layout_margintop= "24DP" android:layout_torightof= "@+id/cbphone" android:text= "Please enter Phone Number "Android:texTcolor= "#ff008000"/> <button android:id= "@+id/btnlisten" android:layout_width= "270DP" Andro        id:layout_height= "40DP" android:layout_alignleft= "@+id/cbloc" android:layout_alignright= "@+id/btnSet" android:layout_below= "@+id/cbloc" android:layout_margintop= "10DP" android:background= "#ff00ff00" and roid:text= "Start monitoring" android:textcolor= "@drawable/white" android:textsize= "30DP"/> <button Android Oid:id= "@+id/btnset" android:layout_width= "206DP" android:layout_height= "41DP" Android:layout_alignpa        Rentbottom= "true" android:layout_alignright= "@+id/txtnumber" android:layout_torightof= "@+id/textView1"        Android:background= "#5f888888" android:text= "Settings" android:textcolor= "@drawable/white"/> <button Android:id= "@+id/btnexit2" android:layout_width= "206DP" android:layout_height= "42DP" Android:la Yout_alignleft= "@+id/btnListen "android:layout_alignparentbottom=" true "android:layout_alignright=" @+id/cbloc "android:backgr Ound= "#5f888888" android:text= "return" android:textcolor= "@drawable/white"/></relativelayout>

Lmainactivity.java:

Package Com.example.whereareyou;import Android. R.drawable;import Android.os.bundle;import Android.app.activity;import Android.content.intent;import Android.graphics.color;import Android.graphics.drawable.drawable;import Android.view.menu;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.checkbox;import Android.widget.edittext;import Android.widget.toast;public class LMainActivity Extends Activity{edittext Txtnumber; CheckBox Cbphone; CheckBox cbsms; CheckBox Cbcall; CheckBox cbring; CheckBox Cbvib; CheckBox Cbloc; Button Btnlisten; Button Btnset; Button btnExit2; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_lmain); txtnumber = (EditText) This.findviewbyid (r.id.txtnumber); CbPhone = ( CheckBox) This.findviewbyid (r.id.cbphone), cbsms = (checkbox) This.findviewbyid (r.id.cbsms); cbcall = (checkbox) This.findviewbyid (r.id.cbcall); cbring = (CheckBox) this.fiNdviewbyid (r.id.cbring); cbvib = (checkbox) This.findviewbyid (R.ID.CBVIB); cbloc = (checkbox) This.findviewbyid ( R.ID.CBLOC); btnlisten = (Button) This.findviewbyid (r.id.btnlisten); btnset = (Button) This.findviewbyid (R.id.btnset); BtnExit2 = (Button) This.findviewbyid (r.id.btnexit2); Btnlisten.setonclicklistener (new Onclicklistener () {@ overridepublic void OnClick (View arg0) {//TODO auto-generated method stubstring number = Txtnumber.gettext (). toString (); if (Number.trim () Equals ("")) {//Remove the space before and after Toast.maketext (Lmainactivity.this, "Please enter phone number", +). Show (); return;} Boolean isphone = Cbphone.ischecked (); Boolean issms = Cbsms.ischecked (); Boolean iscall = Cbcall.ischecked (); Boolean IsR    ing = cbring.ischecked (); Boolean isvib = Cbvib.ischecked (); Boolean isloc = cbloc.ischecked (); if (isphone| | issms| | iscall| | Isring| | isvib| |    Isloc) {appcontext.setnumber (number);    Appcontext.setcall (Iscall);    Appcontext.setphone (Isphone);    Appcontext.setsms (issms);    Appcontext.setloc (Isloc); Appcontext.setrING (isRing);        Appcontext.setvib (ISVIB);    Intent Intent = new Intent ();        Intent.setclass (Getapplicationcontext (), listenphone.class);    if (Btnlisten.gettext (). toString (). Equals ("Start monitoring")) {Btnlisten.settext ("Stop Monitoring");    Btnlisten.setbackgroundcolor (color.red);    Start Service StartService (intent);    }else{Btnlisten.settext ("Start monitoring");    Btnlisten.setbackgroundcolor (Color.green);    Stop Service StopService (intent);    }}else{Toast.maketext (Getapplicationcontext (), "Please select the Monitoring Project", "()." Show ();    return; }}); Btnset.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated Method Stubintent Intent = new Intent (); Intent.setclass (Lmainactivity.this, Smainactivity.class); StartActivity ( Intent);}); Btnexit2.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated Method Stubsystem.exit (0);}}); @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//InflateThe menu; This adds items to the action bar if it is present.getmenuinflater (). Inflate (R.menu.main, menu); return true;}}

There's no technical content on the back.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Small project where is you monitor

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.