Skip to content

Android app, "No apps can perform this action" error #44

Open

Description

@LunXyy

Hello, I have an issue when trying to pick files. It works in editor and in build on my computer, it also works with unity remote. When I Try to build it and a phone, even If the application have the rights to access the files (I also looked at the android manifest), the message "No apps can perform this action" appears. I tried on Bluestacks, Xiaomi, Huawei but still the same error. I saw some post, saying that it's because I have no application to pick the files, but since I'm using one (UnityNativeFilePicker isn't an app, but it should handle this I think) I don't really understand the problem, I have no compilation errors or anything, also the message appears before any folder/ file get displayed.

Sorry if my English is bad, I hope someone has a solution

Activity

  1. yasirkula commented on Jul 20, 2023

    @yasirkula
    Owner

    Hi, can I see your code?

  2. LunXyy commented on Jul 21, 2023

    @LunXyy
    Author

    using System.Collections;
    using System.IO;
    using UnityEngine;
    using UnityEngine.UI;

    public class FilePickerSystem : MonoBehaviour
    {

    public string finalPath;
    
    
    public static FilePickerSystem instance;
    
    private void Awake()
    {
        if(instance != null)
        {
            Debug.LogWarning("Il y a plus d'une instance FilePickerSystem dans la scène");
            return;
        }
    
        instance = this;
    }
    
    private void Start()
    {
        Debug.Log(NativeFilePicker.CheckPermission(false));
        NativeFilePicker.RequestPermission(false);
        NativeFilePicker.OpenSettings();
    }
    
    
    
    public string LoadFile()
    {
        string fileType = NativeFilePicker.ConvertExtensionToFileType("wav,aiff,pcm,flac,alac,wma,mp3,ogg,aac,au,mid,midi,");
        finalPath = null;
        NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
        {
           if (path == null)
           {
           Debug.Log("operation cancelled");
           }
           else
           {
            finalPath = path;
            Debug.Log("Picked file : " + finalPath);
           }
        }, new string[] {fileType});
        return finalPath;
    }
    

    }

  3. LunXyy commented on Jul 21, 2023

    @LunXyy
    Author

    I also have this in another script, I know the WWW class is outdated, but it seems like there wasn't any problem

    public IEnumerator LoadSound(string name, string _path)
    {
    WWW request = GetAudioFromFile(_path, name);
    yield return request;
    AudioClip audioClip = request.GetAudioClip();
    audioClip.name = name;
    buttons.Last().button.GetComponent().clip = audioClip;
    }

    public WWW GetAudioFromFile(string path, string filename)
    {
        WWW request = new WWW(path);
        return request;
    }
    
  4. yasirkula commented on Jul 21, 2023

    @yasirkula
    Owner

    ConvertExtensionToFileType accepts a single extension. You can call it as many times as you wish, one call per extension.

  5. LunXyy commented on Jul 24, 2023

    @LunXyy
    Author

    changed it
    string fileType = NativeFilePicker.ConvertExtensionToFileType("mp3");
    but still the same problem, still work in editor but not in build

  6. yasirkula commented on Jul 24, 2023

    @yasirkula
    Owner

    I wish I knew why, it just should've worked 😞

  7. NIKOLAOS77 commented on Aug 1, 2023

    @NIKOLAOS77

    have the same problem. Using a samsung although i think that doesnt matter.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using System.IO;
    using UnityEngine.UI;

    public class filePickerSystem : MonoBehaviour
    {

    public string FinalPath;
    
    public Image ima;
    
    public void LoadFile()
    {
        string FileType = NativeFilePicker.ConvertExtensionToFileType("*");
        NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
        {
            if (path == null)
            {
    
            }
            else
            {
                FinalPath = path;
                Sprite sprite = Sprite.Create(LoadPNG(FinalPath), new Rect(0, 0, 400, 400), new Vector2(0.5f, 0.0f), 1.0f);
                ima.sprite = sprite;
            }
        }, new string[] { FileType });
        
    }
    
    public void SaveFile()
    {
        string filePath = Path.Combine(Application.temporaryCachePath, "test.txt");
        File.WriteAllText(filePath, "Hello world!");
        NativeFilePicker.Permission permission = NativeFilePicker.ExportFile(filePath, (success) => Debug.Log("file exported: " + success));
        
    }
    public static Texture2D LoadPNG(string filePath)
    {
    
        Texture2D tex = null;
        byte[] fileData;
    
        if (File.Exists(filePath))
        {
            fileData = File.ReadAllBytes(filePath);
            tex = new Texture2D(2, 2);
            tex.LoadImage(fileData); //..this will auto-resize the texture dimensions.
        }
        return tex;
    }
    

    }
    i get the following message
    Screenshot_20230801_122954_Android System

  8. yasirkula commented on Aug 2, 2023

    @yasirkula
    Owner

    @NIKOLAOS77 ConvertExtensionToFileType accepts only a valid extension. You can pass "*/*" directly to PickFile (without passing it to ConvertExtensionToFileType) to achieve the desired effect on Android.

  9. Nischal-012 commented on Aug 7, 2023

    @Nischal-012

    It seems like you can directly use "audio/*" on PickFile method and being able to select audio files.

  10. Mashimaro7 commented on Dec 14, 2023

    @Mashimaro7

    @NIKOLAOS77 ConvertExtensionToFileType accepts only a valid extension. You can pass "*/*" directly to PickFile (without passing it to ConvertExtensionToFileType) to achieve the desired effect on Android.

    I'm using

    {
    	NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    	{
    		if (path == null)
    			Debug.Log("Operation cancelled");
    		else
    			Debug.Log("Picked file: " + path);
    	}, new string[] { ".png" });
    
    	Debug.Log("Permission result: " + permission);
    }
    

    The code directly from the repository instructions, but it's not working. Same error, "No apps can perform this action". I've tried replacing the string array with a single string and it gets the same issue. I'm not even using ConvertExtensionToFileType.

  11. yasirkula commented on Dec 15, 2023

    @yasirkula
    Owner

    You can't pass an extension directly to PickFile. You must pass it to ConvertExtensionToFileType. "*/*" isn't an extension but rather a MIME type which is why it can't be passed to ConvertExtensionToFileType.

  12. Mashimaro7 commented on Dec 15, 2023

    @Mashimaro7

    You can't pass an extension directly to PickFile. You must pass it to ConvertExtensionToFileType. "*/*" isn't an extension but rather a MIME type which is why it can't be passed to ConvertExtensionToFileType.

    oh, okay. I was able to get it working without any extensions, but i tried this

    {
    	string fileType = NativeFilePicker.ConvertExtensionToFileType("/image");
    	NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
    	{
    		if (path == null)
    			Debug.Log("Operation cancelled");
    		else
    			Debug.Log("Picked file: " + path);
    	}, fileType);
    
    	Debug.Log("Permission result: " + permission);
    }
    

    And it had the same issue.

  13. yasirkula commented on Dec 15, 2023

    @yasirkula
    Owner

    "/image" isn't an extension so you shouldn't pass it to ConvertExtensionToFileType 😸 Here's the golden rule: if we are talking about an actual file extension (e.g. png), pass it to ConvertExtensionToFileType. If we're talking about a MIME type (e.g. image/*), don't pass it to ConvertExtensionToFileType (note that passing MIME types like that won't work on iOS since iOS uses UTIs instead of MIME types).

  14. prakyath-07 commented on Jan 7, 2024

    @prakyath-07

    I'm still getting the same issue. No apps to perform this action.
    Device Tested : Google Pixel 6a

    private string[] allowedImageTypes = { "png"};
    private void OnImageSelectionClicked()
            {
                NativeFilePicker.PickFile(OnModelPicked, allowedImageTypes);
            }
    
  15. yasirkula commented on Jan 7, 2024

    @yasirkula
    Owner

    @prakyath-07 Try this: NativeFilePicker.PickFile(OnModelPicked, NativeFilePicker.ConvertExtensionToFileType("png"));

  16. prakyath-07 commented on Jan 11, 2024

    @prakyath-07

    @yasirkula Thanks for the reply. this works, but not able to pick fbx files, Getting same warning "No apps can perform this action"

  17. yasirkula commented on Jan 11, 2024

    @yasirkula
    Owner

    @prakyath-07 FBX doesn't have a MIME type as far as I can see. You could try NativeFilePicker.PickFile(OnModelPicked, "application/octet-stream") on Android and when the user selects a file, verify that its extension is fbx (selection won't be limited to fbx).

  18. prakyath-07 commented on Jan 28, 2024

    @prakyath-07

    Thanks :) this works only on Android, any alternative for iOS?

  19. prakyath-07 commented on Jan 28, 2024

    @prakyath-07

    NativeFilePicker.PickFile(OnModelPicked, NativeFilePicker.ConvertExtensionToFileType("png"));

    How do I allow user to select video or image (png, jpeg, mp4)?

  20. prakyath-07 commented on Jan 29, 2024

    @prakyath-07

    Any updates?

  21. yasirkula commented on Jan 29, 2024

    @yasirkula
    Owner

    @prakyath-07 To be able to pick all files: https://forum.unity.com/threads/native-file-picker-for-android-ios-open-source.912890/page-3#post-8987518 (or you could limit the selection to FBX files on iOS by declaring a custom file type via Window-NativeFilePicker Custom Types on iOS). You can also pass multiple file types to PickFile function since it takes a string array.

  22. prakyath-07 commented on Jan 29, 2024

    @prakyath-07

    image

    still not able to select media file with multiple formats

  23. yasirkula commented on Jan 29, 2024

    @yasirkula
    Owner

    NativeFilePicker.PickFile(OnMediaFilePicked, NativeFilePicker.ConvertExtensionToFileType("png"), NativeFilePicker.ConvertExtensionToFileType("jpeg"), NativeFilePicker.ConvertExtensionToFileType("mp4"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions