废话不多说,直接上图,android手机防盗时序图:
          

 

 

android学习之手机防盗One_防盗

 

 其实简单的手机防盗非常好做,那么怎样才能起到防盗效果呢?防盗,防盗,别人顺走你的手机会用来干什么?多半会是自己用,那么盗贼在用你的手机的时候,最先改变的是什么呢?对了,SIM卡,也就是我们常说的电话卡,这就是一个状态的改变。有了这个变量我们这个防盗软件就非常好做了,我们只要得到SIM卡的唯一标识就OK了,那么SIM卡唯一的标识是什么呢?有人肯定会说,电话号码是唯一的标识,但实际上,我们一般的电话卡上面,根本不会有自己号码的记录,那么我们靠什么来做唯一标识呢?我google了下,我们常用的SIM卡上面会有一个IMSI码,百度百科是这样解释,国际移动用户识别码(IMSI:International Mobile SubscriberIdentification Number)是区别移动用户的标志,储存在SIM卡中,可用于区别移动用户的有效信息。其总长度不超过15位,同样使用0~9的数字。既然是唯一标识,那就好办了,我们android手机还是很强大的,androidSDK给我们提供了一个手机管理类(TelephonyManager类),这个类很强大,可以得到SIM卡的绝大数信息。好了,介绍就到这里了,现在开始我们的编程旅程吧!GO
    先来观摩一下主要界面吧(PS:界面粗糙简单之极):
    第一次启动软件:
    
 

android学习之手机防盗One_MIS_02


                                             进入主界面(PS:简单)
    
 

android学习之手机防盗One_android_03


                                              再次进入软件:
    
 

android学习之手机防盗One_防盗_04


                                               些微差别,不知道你发现没有(*^__^*) 
                                                开始防盗:
    
 

android学习之手机防盗One_MIS_05


    好了,界面看到这里,我把布局代码也贴一下吧,方便以后复习:
  1. <!--Main.xml--> 
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     xmlns:tools="http://schemas.android.com/tools" 
  4.     android:layout_width="match_parent" 
  5.     android:layout_height="match_parent" 
  6.     android:paddingBottom="@dimen/activity_vertical_margin" 
  7.     android:paddingLeft="@dimen/activity_horizontal_margin" 
  8.     android:paddingRight="@dimen/activity_horizontal_margin" 
  9.     android:paddingTop="@dimen/activity_vertical_margin" 
  10.     tools:context=".MainActivity" > 
  11.  
  12.     <EditText  
  13.         android:id="@+id/safeNumber" 
  14.         android:layout_width="match_parent" 
  15.         android:layout_height="wrap_content" 
  16.         android:hint="@string/safe_phone" 
  17.         /> 
  18.  
  19.     <Button  
  20.         android:id="@+id/btn_startSafe" 
  21.         android:layout_width="wrap_content" 
  22.         android:layout_height="wrap_content" 
  23.         android:layout_below="@id/safeNumber" 
  24.         android:layout_alignParentLeft="true" 
  25.         android:text="@string/start_safe" 
  26.         /> 
  27.     <Button  
  28.         android:id="@+id/btn_modify" 
  29.         android:layout_width="wrap_content" 
  30.         android:layout_height="wrap_content" 
  31.         android:layout_below="@id/safeNumber" 
  32.         android:layout_alignParentRight="true" 
  33.         android:text="@string/modify" 
  34.         /> 
  35. </RelativeLayout> 


   
  1.  <!--Dialog.xml--> 
  2.     <?xml version="1.0" encoding="utf-8"?> 
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  4.     android:layout_width="match_parent" 
  5.     android:layout_height="match_parent" 
  6.     android:orientation="vertical" > 
  7.      
  8.     <EditText  
  9.         android:id="@+id/et_UserName" 
  10.         android:layout_width="match_parent" 
  11.         android:layout_height="wrap_content" 
  12.         android:hint="@string/user_text" 
  13.         /> 
  14. <EditText  
  15.    android:id="@+id/et_Password" 
  16.    android:layout_width="match_parent" 
  17.    android:layout_height="wrap_content" 
  18.    android:password="true" 
  19.    android:hint="@string/password_text" 
  20.    /> 
  21. <LinearLayout  
  22.    android:orientation="horizontal" 
  23.    android:layout_width="match_parent" 
  24.    android:layout_height="wrap_content" 
  25.    > 
  26.    <Button  
  27.        android:id="@+id/btn_Ok" 
  28.        android:layout_width="wrap_content" 
  29.        android:layout_height="wrap_content" 
  30.        android:layout_weight="1" 
  31.        /> 
  32.    <Button 
  33.        android:id="@+id/btn_cancle" 
  34.        android:layout_width="wrap_content" 
  35.        android:layout_height="wrap_content" 
  36.        android:layout_weight="1" 
  37.        /> 
  38. </LinearLayout> 
  39. </LinearLayout> 

是不是很简单,呵呵,简单就对了,其实都没什么难的!