我想在我的應用程序中有一個按鈕,當按下時,用戶被帶到手機內置畫廊應用程序。如果可能的話,我希望用戶被帶到應用程序創建的目錄。有沒有辦法在Android中做到這一點?如果應用在進入畫廊後結束,那就沒問題了。有按鈕,可以自動將您帶到畫廊
-1
A
回答
0
試試這個代碼...!
Button btn =(Button)findViewById(R.id.btn);
btn.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Picture"), 0);
}
});
0
您可以使用意圖在android系統使用defalut畫廊和這裏的代碼是 -
按鈕GalleryButton =(按鈕)this.findViewById(R.id.galleryview); GalleryButton.setOnClickListener(新OnClickListener(){
public void onClick(View arg0) {
// in onCreate or any event where your want the user to
// select a file
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
Uri selectedImageUri = data.getData();
filemanagerstring = selectedImageUri.getPath();
selectedImagePath = getPath(selectedImageUri);
if(selectedImagePath!=null)
System.out.println(selectedImagePath);
else System.out.println("selectedImagePath is null");
if(filemanagerstring!=null)
System.out.println(filemanagerstring);
else System.out.println("filemanagerstring is null");
if(selectedImagePath!=null)
System.out.println("selectedImagePath is the right one for you!");
else
System.out.println("filemanagerstring is the right one for you!");
}
}
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
if(cursor!=null)
{
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
else return null;
}
相關問題
- 1. 滾動畫廊的按鈕
- 2. 畫廊滾動時點擊按鈕?
- 3. textview與按鈕在畫廊
- 4. Featherlight.JS:畫廊是否有按鈕
- 5. blueimp畫廊將在圖像刪除按鈕始終打開畫廊
- 6. 自動推進畫廊動畫
- 7. 您可以將按鈕添加到smartgwt中的樹上嗎?
- 8. 將選項添加到移動畫廊?
- 9. 停用畫廊滑塊上的按鈕
- 10. 停用畫廊滑塊上的按鈕
- 11. 帶有setScaleX/Y的兒童畫廊
- 12. 圖片自畫廊自動旋轉 - Android
- 13. 帶覆蓋按鈕的動畫UIImageView
- 14. 帶動畫的UIButton圖像按鈕
- 15. 帶觸發按鈕的動畫製作
- 16. Android - 有沒有辦法告訴後退按鈕將帶您到哪個Intent?
- 17. 您可以將NavigateUrl直接添加到帶有動態參數的頁面嗎?
- 18. 將動畫SWF加載到自定義Flex(火花)按鈕中
- 19. 按鈕按動畫
- 20. facebook喜歡按鈕動態縮略圖與ajax畫廊
- 21. 我在js中的畫廊按鈕將不起作用
- 22. 動畫按鈕
- 23. 畫廊以兩邊
- 24. 如何自動將按鈕移動到另一個按鈕?
- 25. Fancybox沒有導航按鈕,但畫廊作品
- 26. 有照片和畫廊的按鈕iOS的全局菜單
- 27. 將音樂添加到Java中帶有動畫的動畫
- 28. 與畫廊活動
- 29. IOS滾動畫廊
- 30. 自動在頁面畫廊wordpress
做出帶你到gallery.with點擊數事件 – Giant
重複的意圖 - [如何打開通過代碼手機圖庫]( http://stackoverflow.com/questions/6016000/how-to-open-phones-gallery-through-code) – neo108