Intent mainly includes implicit intent and explicit intent. Explicit intent is usually used to start data between activities in the current application, while implicit intent is commonly used in some specific actions in the startup system, such as making phone calls or sending text messages, or cross-app Activity startup (for example, clicking the link address on QQ to start a browser Activity ).
Explicit Intent: Call Intent. setComponent (), Intent. setClass (), Intent. the setClassName () method explicitly specifies the Intent of the component name as the explicit Intent, and the explicit Intent specifies the component to which the Intent should be passed.
Implicit Intent: Intent without explicitly specifying the component name is implicit Intent. The Android system will find the most suitable component to process the intent based on the action, category, and data (URI and data type) set in the implicit intent.
MainActivity. java
Package cn. android. intent; import java. util. date; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. view. keyEvent; import android. view. view; import android. widget. textView; public class NewActivity extends Activity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {// TODO Auto-generated method stubsuper. onCreate (savedInstanceState); setContentVi Ew (R. layout. other); Intent intent = getIntent (); // Log. I ("NewActivity", intent. getData (). getPath (); String title = intent. getStringExtra ("title"); double since = intent. getDoubleExtra ("since", 1995.5); TextView textView = (TextView) this. findViewById (R. id. textView); textView. setText ("language:" + title + ", Release Date:" + since + ". ");} Public void closeActivity (View v) {Intent intent = new Intent (); intent. putExtra ("result", new Date (). toString (); setResult (501, intent); this. finish () ;}@ Overridepublic boolean onKeyDown (int keyCode, KeyEvent event) {if (keyCode = KeyEvent. KEYCODE_BACK) {closeActivity (null) ;}return true ;}}
NewActivity. java
Package cn. android. intent; import java. util. date; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. view. keyEvent; import android. view. view; import android. widget. textView; public class NewActivity extends Activity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {// TODO Auto-generated method stubsuper. onCreate (savedInstanceState); setContentVi Ew (R. layout. other); Intent intent = getIntent (); // Log. I ("NewActivity", intent. getData (). getPath (); String title = intent. getStringExtra ("title"); double since = intent. getDoubleExtra ("since", 1995.5); TextView textView = (TextView) this. findViewById (R. id. textView); textView. setText ("language:" + title + ", Release Date:" + since + ". ");} Public void closeActivity (View v) {Intent intent = new Intent (); intent. putExtra ("result", new Date (). toString (); setResult (501, intent); this. finish () ;}@ Overridepublic boolean onKeyDown (int keyCode, KeyEvent event) {if (keyCode = KeyEvent. KEYCODE_BACK) {closeActivity (null) ;}return true ;}}
Main. xml
Other. xml
AndroidManifest. xml
windowsphone" />
Strings. xml
Hello World, MainActivity!
New Activity!
Android intent
Show
Open implicit intent
Close Window