Unity and Android Interactive experience

Source: Internet
Author: User

A call to the Android native sharing feature.

No need to speak online in Android studio or eclipse export jar package to Unity then call. Just set up a CS file normally to write the following code.

 Public voidShare (stringSharetext,stringImagePath,stringUrlstringSubject ="")    {#ifUnity_androidAndroidjavaclass Intentclass=NewAndroidjavaclass ("android.content.Intent"); Androidjavaobject Intentobject=NewAndroidjavaobject ("android.content.Intent"); Intentobject.call<AndroidJavaObject> ("setaction", intentclass.getstatic<string> ("Action_send")); Androidjavaclass Uriclass=NewAndroidjavaclass ("Android.net.Uri"); Androidjavaobject Uriobject= Uriclass.callstatic<androidjavaobject> ("Parse","file://"+ImagePath); Intentobject.call<AndroidJavaObject> ("PutExtra", intentclass.getstatic<string> ("Extra_stream"), uriobject); Intentobject.call<AndroidJavaObject> ("SetType","Image/png"); Intentobject.call<AndroidJavaObject> ("PutExtra", intentclass.getstatic<string> ("Extra_text"), Sharetext); Androidjavaclass Unity=NewAndroidjavaclass ("Com.unity3d.player.UnityPlayer"); Androidjavaobject currentactivity= Unity. Getstatic<androidjavaobject> ("currentactivity"); Androidjavaobject Jchooser= Intentclass.callstatic<androidjavaobject> ("Createchooser", Intentobject, subject); Currentactivity.call ("startactivity", jchooser);#endif

Here's a share, without special needs, to call Unity 's own features directly.

string " Screenshot.png " ; string " / " + screenshotname; Application.capturescreenshot (screenshotname);

By default this method is saved in the Application.persistentdatapath , the different platform specific path is not the same. The function name also lets you know that this path is the path to persisting data. I also use the XML file to save the game data .

Two integrated googleplaygame and fyber SDK experience. This is what I have done recently. In normal circumstances, the plug-ins are all imported into it. However, there may be a series of errors, such as packaging is not successful, running a flashback and so on. The causes of this situation are similar, and other SDK issues can be borrowed.

The reasons for the unsuccessful packaging I have encountered the following major situations:

1 cannot merge XML. (Unable to merge Android manifests.)

Cause: This is because there are multiple XML files that have the same label but the content properties are different, resulting in unity not knowing which one to choose.

Solution: Find all the XMLthat you want to pack in, and delete some of the conflicts.

2 can't pack resource (Fail to re-package Resources)

Reason: The declaration refers to a resource that does not exist.

it could be in Androidmanifest.xml . declared in References some non-existent resources. Frequently asked questions are here:

  < Application        Android:allowbackup = "true"        android:theme= "@android: Style/theme.notitlebar"       android:icon= "@ Drawable/app_icon "        android:label=" @string/app_name ">

Solution: Replace the label contents with the above default. This problem is common with native SDK access.

Or your existing jar,the packages that theAAR relies on are not imported. You need to find and import in. Put it in the plugins\android directory.

3 cannot convert to Dex (unable to convert to DEX format)

Cause: There is a conflict between each jarand theAAR package. such as duplicate resource bundles, each associated jar,aar version is different (this situation may be exported but app Flash).

Solution: Find and remove duplicate jars,aar packages, unified, interconnected jars,AAR The version of the package.

For projects that need to use Google service Jar,aar, it is recommended to use a unified Jar,aar processing plug-in that also provides custom import Jar,aar packages.

Address: Https://github.com/googlesamples/unity-jar-resolver

Unity and Android Interactive experience

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.