Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 14, 2016 at 02:50 PM by EnriqueL for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by EnriqueL · Jul 02, 2015 at 11:11 AM · c#androidjavajava to c#

Error building with custom java code [Solved]

I'm doing a game that needs to access the calendar in the mobile and save an event, i've build a java code and created a .jar file using Dr. Java:

 package com.company.productname;
 
 import com.unity3d.player.UnityPlayer;
 import com.unity3d.player.UnityPlayerActivity;
 
 import java.util.Calendar;
 import android.os.Bundle;
 
 import android.app.PendingIntent;
 import android.content.Intent;
 import android.content.Context;
 
 import android.util.Log;
 import android.os.Handler;
 
 public class CalendarDate  {
    public void addEvent(Context ctx, String title) {
     //Log.d(TAG, "AddUsingIntent.addEvent()");
     Intent intent = new Intent(Intent.ACTION_EDIT);
     intent.setType("vnd.android.cursor.item/event");
     intent.putExtra("title", title);
     //intent.putExtra("beginTime", start.getTimeInMillis());
     //intent.putExtra("endTime", end.getTimeInMillis());
     intent.putExtra("allDay", true);
     ctx.startActivity(intent);
 }
 }

and i've added to the mannifest:

   <service android:name="es.astronauts.opengl.CalendarDate" />

to be able to access from a C# code, the code is:

 #if UNITY_ANDROID
     private AndroidJavaObject playerActivityContext;
     #endif
     // Use this for initialization
     void Start () {
         inicio = 2015914730;
         fin = 2015914830;
         #if UNITY_ANDROID && !UNITY_EDITOR
         // Obtain unity context
         if(playerActivityContext == null) {
             AndroidJavaClass actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
             playerActivityContext = actClass.GetStatic<AndroidJavaObject>("currentActivity");
         }
         AndroidJavaClass jc = new AndroidJavaClass(packageName + ".CalendarDate");
         jc.CallStatic("addEvent", playerActivityContext,Title);
         #endif
 
     
     }

but when i build i get the next error: Unity error

can anyone help me? Thank you so much!!

errorunity.jpg (139.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by EnriqueL · Jul 06, 2015 at 08:15 AM

In order to solve this issue i've created a new folder called libs (with ans s) inside the assets folder, and drooped there the java clases

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Faster way to Pass data from C# to Java (Android) 1 Answer

Getting String from Java Class on Android 0 Answers

How to write a java lib for unity as a plugin to make run another android app? 1 Answer

Multiple Cars not working 1 Answer

Can't start a Handler on the main thread 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges