Vote count:
0
I am using the following code for selecting file, it opens file manager to select a file.
What I want is to show a dialog to choose the application first for selecting a file, as shown in the image: http://ift.tt/SFOevm
public class ActivityTestActivity extends Activity {
final int ACTIVITY_CHOOSE_FILE = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button) this.findViewById(R.id.Button01);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent chooseFile;
Intent intent;
chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("file/*");
intent = Intent.createChooser(chooseFile, "Choose a file");
startActivityForResult(intent, ACTIVITY_CHOOSE_FILE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case ACTIVITY_CHOOSE_FILE: {
if (resultCode == RESULT_OK){
Uri uri = data.getData();
String filePath = uri.getPath();
}
}
}
}
}
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire