Android Activity和Intent机制
2010-08-14 00:33:00 来源:WEB开发网Intent-Filter的定义
一些属性设置的例子:
< action android:name="com.example.project.SHOW_CURRENT" />
< category android:name="android.intent.category.DEFAULT" />
< data android:mimeType="video/mpeg" android:scheme="http" . . . />
< data android:mimeType="image/*" />
< data android:scheme="http" android:type="video/*" />
完整的实例
< activity android:name="NotesList" android:label="@string/title_notes_list"> < intent-filter> < action android:name="android.intent.action.MAIN" /> < category android:name="android.intent.category.LAUNCHER" /> < /intent-filter> < intent-filter> < action android:name="android.intent.action.VIEW" /> < action android:name="android.intent.action.EDIT" /> < action android:name="android.intent.action.PICK" /> < category android:name="android.intent.category.DEFAULT" /> < data android:mimeType="vnd.android.cursor.dir/vnd.google.note" /> < /intent-filter> < intent-filter> < action android:name="android.intent.action.GET_CONTENT" /> < category android:name="android.intent.category.DEFAULT" /> < data android:mimeType="vnd.android.cursor.item/vnd.google.note" /> < /intent-filter> < /activity>
Intent用法实例
1.无参数Activity跳转
Intent it = new Intent(Activity.Main.this, Activity2.class);
startActivity(it);
2.向下一个Activity传递数据(使用Bundle和Intent.putExtras)
Intent it = new Intent(Activity.Main.this, Activity2.class);
Bundle bundle=new Bundle();
bundle.putString("name", "This is from MainActivity!");
it.putExtras(bundle); // it.putExtra(“test”, "shuju”);
startActivity(it); // startActivityForResult(it,REQUEST_CODE);
更多精彩
赞助商链接