2017-04-02 19 views
0

インテントを使用して特定のフォルダを開きたいのですが、現在はファイルマネージャが使用可能なときにのみ動作します。ファイルマネージャが存在しない場合でもフォルダを開きたい場合は、すべてのヘルプはここインテントを使用してフォルダを開く

を理解されるであろうどのような変化が、私は私のコードを作成する必要があり、ファイルマネージャは、私のコードの意図を使用して

Button button=(Button)rootview.findViewById(R.id.button); 
    button.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 


      Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + "/AudioRecords/"); 
      Intent intent = new Intent(Intent.ACTION_VIEW); 
      intent.setDataAndType(selectedUri, "resource/folder"); 

      if (intent.resolveActivityInfo(getActivity().getPackageManager(), 0) != null) 
      { 
       startActivity(intent); 
      } 
      else 
      { 
       // if you reach this place, it means there is no any file 
       // explorer app installed on your device 
      } 

     } 
    }); 

答えて

1

オープンフォルダで、私も、ファイル、フォルダを開きたいですマネージャーはいません

ファイルマネージャがインストールされていないAndroid APIバージョン19(KITKAT)では実行できません。

public void openFolder() 
{ 
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() 
    + "/myFolder/"); 
intent.setDataAndType(uri, "text/csv"); 
startActivity(Intent.createChooser(intent, "Open folder")); 
} 
+0

私のコードのelse部分にコードを書く必要がありますか? @darish –

+0

ESファイルマネージャが存在すればコードが実行されるはずですが、実行する方法は何ですか? –

+0

@Jaison_Joseph何が問題なのですか?私のコードをelse部分に貼り付けてください – Darish

関連する問題