One Android app Program It is mainly to set the scene mode on a regular basis, so we need to call the flight mode through programming. After searching, we cannot find the relevant explanations and descriptions, finally, I saw a solution on a foreign forum and finally solved the problem. Code As follows: 1 // Skip row Mode
2 Protected Void Offline ( Boolean Setairplane ) {
3 Settings . System . Putint ( Getcontentresolver (),
4 Settings . System . Airplane_mode_on , Setairplane ? 1 : 0 );
5 Intent Intent = New Intent ( Intent . Action_airplane_mode_changed );
6 Intent . Putextra ( "Testcode" , "Ellic" );
7 Sendbroadcast ( Intent );
8
9 }
We can use airplanemodeon = settings. system. getint (mcontext. getcontentresolver (), settings. system. airplane_mode_on, 0) = 1? True: false; to determine whether the phone is in flight mode.
Next, we will analyze how to call the system program in Android programming. the most convenient way to call the system program is to activate it directly through intent. Intent is really a good thing. If you are free, you have to worry about it. Here are several examples:
1. Call the system email program
- Final intent emailintent = new intent (Android. content. Intent. action_send); // create an intent object
- Emailintent. settype ("plain/text"); // sets the text format
- Emailintent. putextra (Android. content. Intent. extra_email, new string [] {}); // you can specify the recipient's email address.
- Emailintent. putextra (Android. content. Intent. extra_subject, "Hello World !"); // Set the title content
- Emailintent. putextra (Android. content. Intent. extra_text, "It is body-Hello world !"); // Set the mail text content
- Startactivity (intent. createchooser (emailintent, "sending mail ...")); // Start a new activity
2. Call the system SMS Program
- Uri uri = URI. parse ("smsto: 0800000123 ");
- Intent it = new intent (intent. action_sendto, Uri );
- It. putextra ("sms_body", "the SMS text ");
- Startactivity (it );
3. When calling the system alarm program, it must be noted that the calling of the system alarm program should be noted that different sdks and classname are different, and the Android devices produced by different manufacturers may be different, in Motorola's defy, The classname of the alarm is com. motorola. blur. alarmclock instead of COM. android. alarmclock. alarmclock, so we need to modify this method accordingly: public intent setclassname (string packagename, string classname ).
- Intent intent = new intent ();
- Intent. setclassname ("com. Android. alarmclock", "com. Android. alarmclock. alarmclock ");
- Startactivity (intent );