Wednesday, May 6, 2009

intent用法收集

1. 從AP開啟控制台location的設定
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));



2.從AP開啟android內部圖庫,並傳回選擇的圖片

startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), SELECT_IMAGE);

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SELECT_IMAGE)
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = data.getData();
// TODO Do something with the select image URI
}
}



3. 切換到另外一個class視窗

Intent intent = new Intent(this, RedirectGetter.class);
startActivityForResult(intent, INIT_TEXT_REQUEST);

No comments:

Post a Comment