91.手机防盗保护开启关闭
2017-03-22 02:06
141 查看
通过监听防盗保护勾选的状态,分别保存不同的sMpr值,之后根据读取的值来判断是否需要设置相关的参数
布局页面Setup4_activity.xml
监控放到保护的开启与关闭SettupActivity.java
LostAndFindActivity.java
布局页面Setup4_activity.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ldw="http://schemas.android.com/apk/res/com.ldw.safe" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView style="@style/TitleStyle" android:text="4.恭喜您设置完成" /> <CheckBox android:id="@+id/cb_protect" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="防盗保护没有开启" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/presence_invisible"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/presence_invisible"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/presence_invisible"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/presence_online"/> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/phone" /> <Button style="@style/NextStyle" android:text="设置完成" /> <Button style="@style/PreviousStyle" /> </RelativeLayout> </LinearLayout>
监控放到保护的开启与关闭SettupActivity.java
package com.ldw.safe.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import com.ldw.safe.R; /* * 手机防盗第四个设置向导页面 */ public class Setup4Activity extends BaseSetupActivity { private CheckBox cbProtect; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setup4); cbProtect = (CheckBox) findViewById(R.id.cb_protect); //根据保存的状态保存是否开启 boolean protect = mPref.getBoolean("protect", false); if(protect){ cbProtect.setText("防盗保护已经开启"); cbProtect.setChecked(true); }else{ cbProtect.setText("防盗保护没有开启"); cbProtect.setChecked(false); } //监听checkBox,并保存checkbox状态 cbProtect.setOnCheckedChangeListener(new OnCheckedChangeListener(){ @Over 4000 ride public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ cbProtect.setText("防盗保护已经开启"); mPref.edit().putBoolean("protect", true).commit(); }else{ cbProtect.setText("防盗保护没有开启"); mPref.edit().putBoolean("protect", false).commit(); } } }); } //显示上一页,这个需要子类去实现,跳转的页面不是固定的 public void showPrevious(){ //页面跳转 startActivity(new Intent(Setup4Activity.this, Setup3Activity.class)); //销毁当前页面 finish(); //两个界面的切换动画 overridePendingTransition(R.anim.tran_previous_in, R.anim.tran_previous_out);//进入动画和推出动画 } //显示下一页,这个需要子类去实现,跳转的页面不是固定的 public void showNext(){ //页面跳转 startActivity(new Intent(Setup4Activity.this, LostAndFind.class)); //销毁当前页面 finish(); //更新mPref表示已经展示过设置向导,下次进来不展示更新向导 mPref.edit().putBoolean("configed", true).commit(); //两个界面的切换动画 overridePendingTransition(R.anim.tran_in, R.anim.tran_out);//进入动画和推出动画 } }同时在初始化进入的页面,根据防盗功能的开启和关闭初始化安全号码
LostAndFindActivity.java
package com.ldw.safe.Activity; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.ldw.safe.R; /* * 手机防盗页面 */ public class LostAndFind extends Activity { private SharedPreferences mPref; private TextView tvSafePhone; private ImageView ivProtect; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //判断是否是第一次登陆,第一次登陆会进入设置向导 mPref = getSharedPreferences("config", MODE_PRIVATE); boolean configed = mPref.getBoolean("configed", false); if(configed){ //进入手机放到主页面 setContentView(R.layout.activity_lostfind); //从mPref中获取到安全号码 tvSafePhone = (TextView) findViewById(R.id.tv_safe_phone); String phone = mPref.getString("safe_phone", ""); tvSafePhone.setText(phone); //从mPref中获取是否是开启保护的状态,来选择后面的图片是开启还是关闭 ivProtect = (ImageView) findViewById(R.id.iv_protect); boolean protect = mPref.getBoolean("protect", false); if(protect){ ivProtect.setImageResource(R.drawable.lock); }else{ ivProtect.setImageResource(R.drawable.unlock); } }else{ //跳转到设置向导页 startActivity(new Intent(LostAndFind.this, Setup1Activity.class)); finish(); } } /* * 重新进入设置向导 */ public void reEnter(View v){ startActivity(new Intent(LostAndFind.this, Setup1Activity.class)); finish(); } }
相关文章推荐
- ios获取手机用户是否开启关闭静音
- 安卓系统如何开启和关闭插入耳机时弹出的保护听力对话框
- 关闭内存页保护开启内存页保护cr0
- Android手机蓝牙的开发——(一)蓝牙的开启关闭配对等基本操作
- 判断手机相机状态是开启还是关闭
- 安卓开发小练手之手机卫士开发(3)——手机防盗界面的开启
- 系统“文件保护”的开启、关闭、应用方法
- 命令行开启/关闭DEP保护
- CSDN学霸课表——反黑客电脑手机QQ密码防盗网购安全保护隐私
- android关闭手机实体按键开启虚拟按键
- 苹果手机开启关闭信号数字
- Windows Vista平台IE7保护模式是开启还是关闭?
- windows 7 数据执行保护 开启关闭方法
- 安装了APK到手机后,发现软件一开启则关闭
- Win7系统激活工具之小马工具-您关闭了软件保护服务,请在服务中开启后重新激活
- [管理篇6]使用Linux Shell管理OpenStack的虚拟机——批量创建、开启、关闭虚拟机
- Ubuntu开启WiFi热点(安卓手机可识别)
- MTK feature phone 音频功放开启关闭驱动示例
- Mac OS X中开启或关闭显示隐藏文件
- sqlServer把数据库导入导出Excel表&&开启关闭xp_cmdshell和Ad HocDistributed Queries