GithubHelp home page GithubHelp logo

bitcoder0 / unityandroidnativefileopener Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andy-roger/unityandroidnativefileopener

0.0 0.0 0.0 49 KB

Open files from a Unity app natively on an Android device.

Java 84.91% C# 15.09%

unityandroidnativefileopener's Introduction

Unity Android Native File Opener

Open files from a Unity application natively on an Android device. Android recently added more security measures to restrict access to files from outside of an application. It used to be possible to open files with Unity's Application.OpenUrl() method on Android but now it requires a little more work to achive this. This plugin has been tested on Android Version 8, Unity Version 2018.2.17f1, and the "Internal" build system.

How to set it up:

How to use the example:

  • Add an AndroidManifest.xml file into the Assets/Plugins/Android folder
  • If you do not have an AndroidManifest.xml already, you can find the Unity generated Android Manifest file in your ProjectName/Temp/StagingArea after you build the project once.
  • Nest the below snippet inside of the AndroidManifest's <application></application>: tag.
<provider
  android:name="com.cartoontexas.andyr.unityplugin.UnitySSContentProvider"
  android:authorities="a_very_unique_name"
  android:exported="false"
  android:grantUriPermissions="true" />
  • The android:authorities attribute should be a unique name, make this your app bundleID to assure uniqueness.
  • Open example scene: "AndroidNativeFileOpenerExample"
  • Add the example scene to your build settings and build to your device.
  • When done, open app, tap the scene and a frog GIF should be downloaded locally and appear in your default Android GIF viewer.
  • Feel free to try the other examples in the example script which can be uncommented and used.

How to use the API:

  • Prepare the build using the steps above.
  • Create a reference to a file on your device.
  • Insert AndroidContentOpenerWrapper.OpenContent(pathToYourLocalFile); in your code.

Credits: Much of this plugin was adapted from yasirkula (thanks for the help!) UnityNativeShare

unityandroidnativefileopener's People

Contributors

andy-roger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.