一、三种启动方法
setComponent
ComponentName comp = new ComponentName( this, SecondActivity.class); Intent intent = new Intent(); intent.setComponent(comp); startActivity(intent);
setClass
public Intent setClass( Context packageContext, Class<?> cls) Intent intent = new Intent(); intent.setClass(this, SecondActivity.class); startActivity(intent);
intent构造方法
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
二、数据传递
public Intent putExtras(Bundle extras) public Bundle getExtras()
数据返回
public void startActivityForResult( Intent intent, int requestCode);
public final void setResult( int resultCode, Intent data);
protected void onActivityResult( int requestCode, int resultCode, Intent data)
三、手势探测
public GestureDetector(Context context, GestureDetector.OnGestureListener listener)
重写
public boolean onTouchEvent(MotionEvent event) {
return gd.onTouchEvent(event);
}
四、隐式启动
1、
启动浏览器
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN); intent.addCategory( Intent.CATEGORY_APP_BROWSER);
startActivity(intent);
2、同时设置Action和DATA属性
public Intent setData(Uri data);
public static Uri parse(String uriString)