所以我正在製作壁紙,我希望用戶選擇一個文件夾。所以我 在首選項中有一個按鈕,打開一個打算 圖像的意圖,但我想要的實際上只是一個目錄(我猜最糟糕的情況是我可以從最後剝離文件名)。所以這是我的第一個 問題:什麼是僅選擇文件夾的最佳方式?意向完成時選擇文件夾意圖&鍛鍊?
第二個問題是我如何獲得有關何時完成目的爲 的通知?
public class FilePreference extends DialogPreference implements
View.OnClickListener
{
public void onClick(View v)
{
// open up a gallery/file browser
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
getContext().startActivity(Intent.createChooser(intent, "Select Folder"));
}