Created
March 9, 2012 13:44
-
-
Save sanderversluys/2006546 to your computer and use it in GitHub Desktop.
Secret Code Trick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.SharedPreferences; | |
import android.preference.PreferenceManager; | |
import android.widget.Toast; | |
public class MySecretBroadcastReceiver extends BroadcastReceiver { | |
public static final String DEBUG_KEY = "DEBUG"; | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); | |
SharedPreferences.Editor editor = prefs.edit(); | |
editor.putBoolean(DEBUG_KEY, !prefs.getBoolean(DEBUG_KEY, false)); | |
editor.commit(); | |
Toast.makeText(context, "DEBUG mode is set to " + prefs.getBoolean(DEBUG_KEY, false), Toast.LENGTH_LONG).show(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<receiver android:name="MySecretBroadcastReceiver"> | |
<intent-filter> | |
<action android:name="android.provider.Telephony.SECRET_CODE" /> | |
<data android:scheme="android_secret_code" android:host="3333" /> | |
</intent-filter> | |
</receiver> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment