Sending and receiving. Activities.


Last Updated:

  1. Swiftwork

    Swiftwork New Member This Topic's Starter

    Joined:
    Jan 21, 2010
    Messages:
    3
    Likes Received:
    0
    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:

    Code (Text):
    1.  
    2. Main.java
    3.  
    4.         //Code + imports above
    5.        public static final int ACTION_PICK_FILE = 0;
    6.  
    7.        //Code above is outside the method body.
    8.  
    9.         button = (Button) findViewById(R.id.button);
    10.     button.setOnClickListener(new View.OnClickListener() {
    11.             public void onClick(View arg0) {
    12.             Intent filebintent = new Intent(arg0.getContext(),Filebrowser.class);
    13.             startActivityForResult(filebintent, ACTION_PICK_FILE);
    14.             }
    15. *        protected void onActivityResult(int requestCode, int resultCode, Intent filebintent)
    16.         {
    17.              switch(requestCode)
    18.              {
    19.                  case ACTION_PICK_FILE:
    20.                  if (resultCode == RESULT_OK)
    21.                  {
    22.                 Bundle bundle = filebintent.getExtras();
    23.                 String select1 = bundle.getString("Selected1");
    24.                 String path1 = select1.getBytes().toString();
    25.                 System.out.println(select1); //Check if there is an output.
    26.                 System.out.println(path1); //Check if there is an output.
    27.                  }
    28.                  break;
    29.              }
    30.             }
    31.      });
    32.     //Code
    33.  
    34.  
    35. Filebrowser.java
    36.  
    37.         //Code + imports above
    38.                OnClickListener okButtonListener = new OnClickListener(){
    39.                     // @Override
    40.                     public void onClick(DialogInterface arg0, int arg1) {
    41.                            Bundle Data = new Bundle();
    42.                            Data.putString("Selected1", aDirectory.getAbsolutePath().toString());
    43.                            Intent mainintent = new Intent();
    44.                            mainintent.putExtras(Data);
    45.                            setResult(RESULT_OK, mainintent);
    46.                            finish();
    47.                     }
    48.                };
    49.         //Code
    50.  
    Thanks in advance!
    /Erik Hughes
     

    Advertisement

Share This Page

Loading...