Intent: When the Activity with the same Intent limit is found, startActivity () will start the Activity.
Phone BROADCASTER:
Intent. setAction ("android. intent. action. CALL ");
Intent. addCategory ("android. intent. category. DEFAULT ");
Intent. setData (Uri. parse ("tel:" + strmobile ));
StartActivity (intent); // The method automatically adds category: android. Intent. category. DEFAULT to intent.
Text message sender:
SmsManager manager = SmsManager. getDefault ();
ArrayList <String> texts = manager. divideMessage (comtent );
For (String text: texts ){
Manager. sendTextMessage (number, null, text, null, null); // parameters 4 and 5 are the sending status of the SMS, and whether the recipient receives the SMS status;
}
Toast. makeText (getApplicationContext (), R. string. success, Toast. LENGTH_LONG). show ();
Tuxi dialog box // Toast. makeText (MainActivity. this, resId, duration); // internal class access external class;
**************************************** ************************
FindViewById (R. id. button); // query the display control by id;
View. OnClickListener (){
@ Override
Public void onClick (View arg0 ){
// Arg0 is the clicked object
}
}
@ + Id/button: In the internal class of the id of the R file, add a constant whose id is "button" and use the value of this constant as the id value of this control;
@ Android: access the R file under the android package;
@ Id/label: access the file whose id is label (relative layout)
Unit test:
Inheritance class: AndroidTestCase
<Instrumentation
Android: name = "android. test. InstrumentationTestRunner"
Android: targetPackage = "com. hellokity"/>
<Application
Android: icon = "@ drawable/ic_launcher"
Android: label = "@ string/app_name">
<Uses-library android: name = "android. test. runner"/>
</Application>
Actual = function ();
Assert. assertEquals (3, actual); Judge whether actual is 3;