Android暗码启动

android permissions express scheme class action

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


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

 

AndroidManifest.xml

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

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.csdn.net/gigatron/article/details/7665413#comments

你可能感兴趣的:(Android暗码启动)