Hello Devs,
I have the problem that even though the activities starts i cannot get the data back from the filebrowser.java. I am not getting any errors except the line begining with the *. The error is code is never used locally. I have also checked the filbrowser and it does give an output with the code "aDirectory.getAbsolutePath().toString()" so the issue is somewhere in the transfer. Code is below:
Thanks in advance!
/Erik Hughes
I have the problem that even though the activities starts i cannot get the data back from the filebrowser.java. I am not getting any errors except the line begining with the *. The error is code is never used locally. I have also checked the filbrowser and it does give an output with the code "aDirectory.getAbsolutePath().toString()" so the issue is somewhere in the transfer. Code is below:
Code:
Main.java
//Code + imports above
public static final int ACTION_PICK_FILE = 0;
//Code above is outside the method body.
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent filebintent = new Intent(arg0.getContext(),Filebrowser.class);
startActivityForResult(filebintent, ACTION_PICK_FILE);
}
* protected void onActivityResult(int requestCode, int resultCode, Intent filebintent)
{
switch(requestCode)
{
case ACTION_PICK_FILE:
if (resultCode == RESULT_OK)
{
Bundle bundle = filebintent.getExtras();
String select1 = bundle.getString("Selected1");
String path1 = select1.getBytes().toString();
System.out.println(select1); //Check if there is an output.
System.out.println(path1); //Check if there is an output.
}
break;
}
}
});
//Code
Filebrowser.java
//Code + imports above
OnClickListener okButtonListener = new OnClickListener(){
// @Override
public void onClick(DialogInterface arg0, int arg1) {
Bundle Data = new Bundle();
Data.putString("Selected1", aDirectory.getAbsolutePath().toString());
Intent mainintent = new Intent();
mainintent.putExtras(Data);
setResult(RESULT_OK, mainintent);
finish();
}
};
//Code
/Erik Hughes