问题
I am working on an AR app which enables the user to upload the .gItf file they downloaded in their phone local storage and place it on AR with Android AR Core.
However, i faced some issues....
1) I can't get the file path about the .gItf file
Isit because of the permission issue?
How I let the user upload file
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("*/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
//To start a activity that will return result
startActivityForResult(intent,PICK_FILES);
//startActivityForResult(Intent.createChooser(intent,"Select your .gITF"),PICK_FILES);
}
How I try to get the path name
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==PICK_FILES && resultCode==RESULT_OK && data != null){
path = data.getData().getPath();
System.out.println(path);
}else{
Toast.makeText(MainActivity.this,"Please select a valid file",Toast.LENGTH_LONG);
}
}
My manifest file
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
What the printIn returnscontent://com.google.android.apps.docs.storage/document/acc=2;doc=encoded=Wsi4zjmWYALAW/AO7bh0PsFGouCMhVw4QQj3XtHR36/iUIjd
instead of something with file//xxxx.gItf
Any solutions? Really need help as I browse alot of online resources but it did not work....
来源:https://stackoverflow.com/questions/59212219/not-getting-the-actual-filepath-from-getpath-and-unable-to-load-gitf-file-fro