Storage Access Framework from NativeScript

6 posts, 1 answers
  1. Dimitar
    Dimitar avatar
    46 posts
    Member since:
    May 2014

    Posted 30 Aug Link to this post

    Hi, 

    Is there a plugin for NativeScript using and accessing the Android Storage Access Framework . Needed for browsing and selecting file .

     

  2. Answer
    nikolay.tsonev
    Admin
    nikolay.tsonev avatar
    290 posts

    Posted 31 Aug Link to this post

    Hello Dimitar,

    For described scenario, I could suggest using nativescript-file-picker plugin, which provides similar functionality. For further help, you could also review the plugin's repository here.


    Let me know, whether this is applicable for you.

    Regards,
    nikolay.tsonev
    Progress Telerik
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
  3. Dimitar
    Dimitar avatar
    46 posts
    Member since:
    May 2014

    Posted 31 Aug Link to this post

    actually as I see I could simple do 

    let intent = new android.content.Intent() ;
     
          intent.setType("image/*");
           
          intent.setAction(android.content.Intent.ACTION_GET_CONTENT);
          intent.addCategory(android.content.Intent.CATEGORY_OPENABLE);
           
         app.android.foregroundActivity.startActivityForResult(intent,42) ;
  4. Dimitar
    Dimitar avatar
    46 posts
    Member since:
    May 2014

    Posted 31 Aug Link to this post

    actually the code which I have psoted in previous post is open the native android picker , but I am not sure how this android override needed result should  be added by nativescript 

    @Override
    public void onActivityResult(int requestCode, int resultCode,
            Intent resultData) {
        if (requestCode == 42 && resultCode == Activity.RESULT_OK) {
                  Uri uri = null;
            if (resultData != null) {
                uri = resultData.getData();
                Log.i(TAG, "Uri: " + uri.toString());
                showImage(uri);
            }
        }
    }

     

  5. Dimitar
    Dimitar avatar
    46 posts
    Member since:
    May 2014

    Posted 31 Aug Link to this post

    I found  way with code : 
    app.android.on(app.AndroidApplication.activityResultEvent, function (args: app.AndroidActivityResultEventData) {
           console.log("Event: " + args.eventName + ", Activity: " + args.activity +
               ", requestCode: " + args.requestCode + ", resultCode: " + args.resultCode + ", Intent: " + args.intent);

     

     

  6. nikolay.tsonev
    Admin
    nikolay.tsonev avatar
    290 posts

    Posted 01 Sep Link to this post

    Hello,

    I glad to hear that you have found a way to handle the response from the Android file picker.
    I tested the attached code and it seems to work as expected and to returns correct path to the selected file.

    Let me know if I could assist you further.

    Regards,
    nikolay.tsonev
    Progress Telerik
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Back to Top