志鸿思荣
2015-11-20 14:55:59
精
安卓客户端开发的锁屏源码demo下载,可直接应用到APP中
安卓程序锁屏
好多安卓APP中都用到锁屏技术在这里只是一个Demo 但是可以直接运用到已经做好的APP中,在绘制锁屏中用到许多的Math函数。
package com.weiqiang.lockpoint; import com.infohold.lockpoint.R; import android.app.Activity; import android.os.Bundle; import android.view.Window;
/** * Email 1107438082@.com * @author 魏强 * 密码绘制成功界面 */
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); } }
package com.weiqiang.lockpoint; import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import com.infohold.lockpoint.R; import com.weiqiang.lockpoint.LockPatternView.OnPatterChangeListner; /** * 密码碎片 * * @author 魏强 * */ public class PasswordFragment extends Fragment implements OnPatterChangeListner, OnClickListener { public static final String TYPE_SETTING = "setting"; public static final String TYPE_CHECK = "check"; private TextView mainLock; private LockPatternView lockPatternView; private LinearLayout btnLinearLayout; private static final String ARG_TYPE = "type"; private String passString; public PasswordFragment() { } public static android.app.Fragment newInstance(String arg_type) { PasswordFragment fragment = new PasswordFragment(); Bundle args = new Bundle(); args.putString(ARG_TYPE, arg_type); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override @Nullable public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_password, container, false); mainLock = (TextView) v.findViewById(R.id.fragment_password_lock_hint); lockPatternView = (LockPatternView) v .findViewById(R.id.fragment_password_lock); btnLinearLayout = (LinearLayout) v .findViewById(R.id.fragment_password_btn_layout); // 设置密码 if (getArguments() != null) { if (TYPE_SETTING.equals(getArguments().getString(ARG_TYPE))) { btnLinearLayout.setVisibility(View.VISIBLE); } } v.findViewById(R.id.fragment_password_btn_commit).setOnClickListener(this); v.findViewById(R.id.fragment_password_btn_forget).setOnClickListener(this); lockPatternView.setPatterChangeListner(this); return v; } @Override public void onPatterChange(String passString) { this.passString = passString; if (!TextUtils.isEmpty(passString)) { mainLock.setText(passString); //没有密码直接进入主页面 // 检查密码 if (getArguments() != null) { if (TYPE_CHECK.equals(getArguments().getString(ARG_TYPE))) { SharedPreferences sp = getActivity().getSharedPreferences("sp", Context.MODE_PRIVATE); // 检查成功 if (passString.equals(sp.getString("password", ""))) { getActivity().startActivity(new Intent(getActivity(), MainActivity.class)); getActivity().finish(); // 检查失败 } else { mainLock.setText("密码错误"); lockPatternView.errorPoint(); } } } } else { mainLock.setText("请设置至少5位密码"); } } @Override public void onPatterStart(boolean isStart) { if (isStart) { mainLock.setText("请绘制图案"); } } @Override public void onClick(View v) { switch (v.getId()) { case R.id.fragment_password_btn_commit: SharedPreferences sp = getActivity().getSharedPreferences("sp", Context.MODE_PRIVATE); // 设置密码 sp.edit().putString("password", passString).commit(); getActivity().finish(); break; case R.id.fragment_password_btn_forget: sp = getActivity().getSharedPreferences("sp",Context.MODE_PRIVATE); // 设置密码 sp.edit().putString("password", "").commit(); startActivity(new Intent(getActivity(), SettingPasswordActivity.class)); getActivity().finish(); break; } } }
package com.weiqiang.lockpoint; import android.app.Activity; import android.os.Bundle; import android.view.Window; /** *设置密码 *Email 1107438082@qq.com * @author 魏强 */ public class SettingPasswordActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getFragmentManager().beginTransaction().replace(android.R.id.content, PasswordFragment.newInstance(PasswordFragment.TYPE_SETTING)).commit(); } }
package com.weiqiang.lockpoint; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; import android.view.Window; /** *Email 1107438082@qq.com *@author 魏强 *欢迎界面 判断是否存在密码 */ public class WelcomeActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); new Handler().postDelayed(new Runnable() { @Override public void run() { SharedPreferences sp = getSharedPreferences("sp", Context.MODE_PRIVATE); String passwordStr = sp.getString("password", ""); //判断是否已经设置过密码 //没有设置过密码 if(TextUtils.isEmpty(passwordStr)){ startActivity(new Intent(WelcomeActivity.this, SettingPasswordActivity.class)); finish(); //解锁 }else { getFragmentManager().beginTransaction().replace(android.R.id.content, PasswordFragment.newInstance(PasswordFragment.TYPE_CHECK)).commit(); } } }, 1000); } }
猜你喜欢
请下载代码后再发表评论
文件名:锁屏.rar,文件大小:2683.106K
下载
- /
- /锁屏
- /锁屏/.classpath
- /锁屏/.project
- /锁屏/AndroidManifest.xml
- /锁屏/bin
- /锁屏/bin/AndroidManifest.xml
- /锁屏/bin/classes
- /锁屏/bin/classes/com
- /锁屏/bin/classes/com/infohold
- /锁屏/bin/classes/com/infohold/lockpoint
- /锁屏/bin/classes/com/infohold/lockpoint/BuildConfig.class
- /锁屏/bin/classes/com/infohold/lockpoint/R$attr.class
- /锁屏/bin/classes/com/infohold/lockpoint/R$dimen.class
- /锁屏/bin/classes/com/infohold/lockpoint/R$drawable.class
- /锁屏/bin/classes/com/infohold/lockpoint/R$id.class
- /锁屏/bin/classes/com/infohold/lockpoint/R$layout.class
- /锁屏/bin/classes/com/infohold/lockpoint
- /锁屏/bin/classes/com/infohold
- /锁屏/bin/classes/com
- /锁屏/gen
- /锁屏/gen/com
- /锁屏/gen/com/infohold
- /锁屏/gen/com/infohold/lockpoint
- /锁屏/gen/com/infohold
- /锁屏/gen/com
- /锁屏/src
- /锁屏/src/com
- /锁屏/src/com/weiqiang
- /锁屏/src/com
- /锁屏
相关代码
最近下载
最近浏览
anjuw521 LV1
7月10日
wwwqwq
6月21日
暂无贡献等级
2636804923 LV6
6月20日
咩咩咩咩咩 LV2
6月17日
yyyyyyzh LV8
2023年6月11日
LITIANYU084414 LV11
2023年1月13日
chenywzid
2022年7月4日
暂无贡献等级
夜上清元 LV8
2022年5月29日
张恺祺 LV6
2022年5月21日
wanglinddad LV55
2022年4月8日