Android暗码启动

本文介绍了一种通过特定拨号盘秘密代码(*#*#4636#*#*)来启动Android设备上的测试设置界面的方法。该方法涉及创建一个名为TestingSettings的活动和一个广播接收器TestingSettingsBroadcastReceiver,当用户输入指定代码时会触发相应的广播并启动测试设置界面。

from: http://shaobin0604.iteye.com/blog/888943


不说啥了:代码来自于 $ANDROID_SOURCE/packages/apps/Settings 

 

AndroidManifest.xml

[java] view plain copy
  1. <activity android:name="TestingSettings" android:label="@string/testing">  
  2. <intent-filter>  
  3. <action android:name="android.intent.action.MAIN"/>  
  4. <category android:name="android.intent.category.DEFAULT"/>  
  5. </intent-filter>  
  6. </activity>  
  7. <receiver android:name="TestingSettingsBroadcastReceiver">  
  8. <intent-filter>  
  9. <action android:name="android.provider.Telephony.SECRET_CODE"/>  
  10. <data android:scheme="android_secret_code" android:host="4636"/>  
  11. </intent-filter>  
  12. </receiver>  

TestingSettingsBroadcastReceiver.java

[html] view plain copy
  1. package com.android.settings;  
  2.   
  3. import android.provider.Telephony;  
  4. import static android.provider.Telephony.Intents.SECRET_CODE_ACTION;  
  5.   
  6. import android.content.Context;  
  7. import android.content.Intent;  
  8. import android.content.BroadcastReceiver;  
  9. import android.util.Config;  
  10. import android.util.Log;  
  11. import android.view.KeyEvent;  
  12.   
  13.   
  14. public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {  
  15.     
  16.     public TestingSettingsBroadcastReceiver() {  
  17.     }  
  18.       
  19.     @Override  
  20.     public void onReceive(Context context, Intent intent) {  
  21.         if (intent.getAction().equals(SECRET_CODE_ACTION)) {  
  22.             Intent i = new Intent(Intent.ACTION_MAIN);  
  23.             i.setClass(context, TestingSettings.class);  
  24.             i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
  25.             context.startActivity(i);  
  26.         }  
  27.     }  
  28. }  


 TestSettings.java

[java] view plain copy
  1. /* 
  2.  * Copyright (C) 2008 The Android Open Source Project 
  3.  * 
  4.  * Licensed under the Apache License, Version 2.0 (the "License"); 
  5.  * you may not use this file except in compliance with the License. 
  6.  * You may obtain a copy of the License at 
  7.  * 
  8.  *      http://www.apache.org/licenses/LICENSE-2.0 
  9.  * 
  10.  * Unless required by applicable law or agreed to in writing, software 
  11.  * distributed under the License is distributed on an "AS IS" BASIS, 
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
  13.  * See the License for the specific language governing permissions and 
  14.  * limitations under the License. 
  15.  */  
  16.   
  17. package com.android.settings;  
  18.   
  19. import android.os.Bundle;  
  20. import android.preference.PreferenceActivity;  
  21.   
  22. public class TestingSettings extends PreferenceActivity {  
  23.   
  24.     @Override  
  25.     protected void onCreate(Bundle savedInstanceState) {  
  26.         super.onCreate(savedInstanceState);  
  27.           
  28.         addPreferencesFromResource(R.xml.testing_settings);  
  29.     }  
  30.   
  31. }  

拨号盘输入 *#*#4636#*#* 就会启动 TestSettings Activity


http://blog.youkuaiyun.com/gigatron/article/details/7665413#comments
### Android 加密与密码处理方法 #### DES 对称加密示例 在Android开发中,可以使用DES算法进行字符串的对称加密。下面是一个简单的例子: ```java // 使用指定字符集和密钥对字符串进行加密 String encryptResult = DesUtil.encrypt(str, CHARSET, SKEY);[^1] ``` 这段代码展示了如何通过`DesUtil`工具类来实现基于DES算法的加密操作。 #### RSA 非对称加密应用实例 对于更高级别的安全性需求,则可以选择采用RSA非对称加密方式。这里给出了一段用于登录密码加密的具体实现代码片段: ```java public class PasswordJiami { public static PublicKey publicKey; public static String passwordjiami(String password){ // 获取公钥并将其转换为PublicKey对象 publicKey = RsaUtils.keyStrToPublicKey(PUBLIC_KEY_STR); // 利用公钥对输入密码执行加密操作 String publicEncryptedResult = RsaUtils.encryptDataByPublicKey( password.getBytes(), publicKey ); return publicEncryptedResult; } } ``` 此部分代码说明了怎样利用给定的公钥完成对用户输入密码的安全编码过程[^3]。 #### ZIP 文件加解密支持库介绍 当涉及到ZIP格式压缩包内含敏感资料时,推荐借助专门设计用来处理此类场景下的第三方库——Zip4J。该库允许开发者轻松地读取/写入带有密码保护机制的ZIP文档,从而有效保障存档内容不被非法访问[^4]: ```java // 创建ZipFile对象,并设置相应的参数选项... zipFile.setPassword("your_password".toCharArray()); ``` 以上就是几种常见的适用于Android平台上的加密技术和相应实践案例分享。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值