Can we access Android's Java Class Object

Hello all,

I have made an Android plugin for unity.
We read our data from a file and store it into an object of a java class.
Now we need to access that object in Unity(using c#) with all the property it has in Java.

For more understanding suppose we have 4 java classes(of Android).We have made a jar file. and put that jar into the unity’s plugin folder.

public class C{

public int num;
public String string;

}

public class B{
public C objC;
public float number;

}

public class A{

public B objB;
public String str;

}

public class UseAndroidActivity extends UnityPlayerActivity{

onCreate(){
A objA = new A();
}
}

Now we need to access or return objA in unity with all the attribute it is having.
Is it possible??
if yes then how??

Please help.

Ok here is the think as I understand it. You can deffinitly return a class from java but it will be a AndroidJavaObject then in order to get strings ints or other objects back form it you need to use calls eg:

//Lets say you returned the below object (it can be watever class you use inside java but it will alway be of type AndroidJavaObjectt)

AndroidJavaObject returnedObject;

Then in order to use methods from that object you use

returnedObject.call<optionalReturnType>("nameOfMethodToCall", arrayOfParametersToSendToMethod[]);

now if you wish to return another object then just use

AndroidJavaObject anotherReturnedObject = returnedObject.call<AndroidJavaObject>("method name that returns some object", arrayOfParametersifAny[]);

then you call rinse and repeat for the returnJava object Above

  1. Learn to use code blocks to format code
  2. You can’t. Your objA only exists within the onCreate block, which is called when the Activity is initialized. Since you don’t store the reference anywhere the only reference (objA) will get removed at the end of the code block and just waiting to be purged from memory by the garbage collection.

Hello Raigex,

Thanks for your support.
I am writing on behalf of UnityTiger.
I am new to unity so please forgive me for my mistakes.

Suppose in the above mentioned example our UseAndroidActivity is implemented as below

public class UseAndroidActivity extends UnityPlayerActivity{

onCreate(){
//some code here
}
public ObjA returnObject(){
ObjA objA = new ObjA();
return objA;
}

}

and in unity we are using your code as below

AndroidJavaObject anotherReturnedObject = returnedObject.call(“returnObject”);

Now my concern is this the anotherReturnedObject will hold all the property that objA is holding in java or we need to access it in some other way.
How can we access string data of objC using objA.

I hope you got my point.

Regards

UnityTigerReturn

Ok If it was me I would do something like this. I havnt tried it so you might have to play with the code.

public class UseAndroidActivity extends UnityPlayerActivity{
     public ObjA returnObject;

     onCreate(){
   
        returnObject = new ObjA();

     }

   public ObjA returnReturnObject()
   {
        return returnObject;
   }

}

Now then if the objects are the same as in the first post then a call for them would look something like this: (this is in unity C# script)

AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); 

AndroidJavaObject mActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");

//get public object info

mActivity.Get<AndroidJavaObject>("returnObject").Get<AndroidJavaObject>("ObjBVariableName").Get<AndroidJavaObject>("ObjCVariableName").Get<string>("stringName");

//This is equivalent to calling this:
//returnObject.ObjBVariable.ObjCVariable.stringName;
// in java

Now as I said before this is just winging it, but it should work.

Also please Use code blocks for ease of understanding. If you dont know how when replying make sure you use advanced and click the # symbol above the text box or write CODE and /CODE in brackets

Not directly.

You can cast your list to an array listObjA.toArray() instead of returning the reference to the list and then use Unity - Scripting API: AndroidJNI.FromObjectArray and get a list of IntPtr (pointers) to the objects.

Or you can loop through it, calling get method (via JNI of course) on the list object and get the elements, process them and add them in your List() in your C#/UnityScript.

Thanks a lot Tseng.

Hello Raigex and Tseng,

Now i have another issue regarding memory leaks.I have tried to resolve it but failed.
I need to call method getPageData, code works fine for 10 times but when i call this method for the 11th time my application get crashed with messages like
Low Memory: No more background processes
getFieldID(“book”, “Ljava/lang/Object;”) FAILED!
JNI: Unable to find field id for ‘book’

here is my code

using UnityEngine;
using System.Collections;
using System;
using System.Text.RegularExpressions;
public class PluginClass : MonoBehaviour {
	
	//Global variable
	AndroidJavaObject page;
	AndroidJavaObject [] phases;
	AndroidJavaObject [] textBlocks;
	AndroidJavaObject [] textWordGroups;
	AndroidJavaObject [] valueArray;
	AndroidJavaObject [] pages;
	AndroidJavaObject [] buttons;
	AndroidJavaObject [] textKaraokeTimings;
	// Use this for initialization
	//AndroidJavaClass cls_UnityPlayer;
	AndroidJavaObject obj_Activity;
	
	void Start ()
	{
		AndroidJNI.EnsureLocalCapacity(500);
		AndroidJNIHelper.debug = true;
		int attachThread = AndroidJNI.AttachCurrentThread();
		if( attachThread == 0){
			print("AndroidJNI thread started successfully");
		}else{
			print("thread started unsuccessful");
		}
        //cls_UnityPlayer= new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    	//obj_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
	}
	
	// Update is called once per frame
	public PageYMLParsing getPageData(int pageArrayIndex)
	{
		
		
		
		
		AndroidJNI.PushLocalFrame(400);
		
		PageYMLParsing pageYMLParsing = new PageYMLParsing();
	using (obj_Activity = (new AndroidJavaClass("com.unity3d.player.UnityPlayer")).GetStatic<AndroidJavaObject>("currentActivity")) 
        {
			
		print("cross page to read "+pageArrayIndex);
			try{
				int numBerOfPages = obj_Activity.Get<AndroidJavaObject>("bookConfig").Get<AndroidJavaObject>("book").Get<AndroidJavaObject>("pages").Call<int>("size");
		  pages = obj_Activity.Get<AndroidJavaObject>("bookConfig").Get<AndroidJavaObject>("book").Get<AndroidJavaObject>("pages").Call<AndroidJavaObject []>("toArray");//OK
				for(int i = 0;i<numBerOfPages;i++){
						AndroidJNI.NewGlobalRef(pages[i].GetRawObject()); 
					}
				
				page = pages[pageArrayIndex];
					for(int i = 0;i<numBerOfPages;i++){
						AndroidJNI.DeleteGlobalRef(pages[i].GetRawObject());
					
						pages[i].Dispose();
					}
		//AndroidJNI.DeleteLocalRef((IntPtr)page);
		//pages = null;
		
		pageYMLParsing.page_id = page.Get<string>("id");
		pageYMLParsing.thumbnail_image = page.Get<string>("thumbnail_image");
		pageYMLParsing.background_image = page.Get<string>("background_image");
		pageYMLParsing.background_audio = page.Get<string>("background_audio");
		pageYMLParsing.popup_text_id_map_image = page.Get<string>("popup_text_id_map_image");
		
		
		
//		pageYMLParsing.text_style.typeface = page.Get<AndroidJavaObject>("popup_text_style").Get<string>("typeface");
//		
//		pageYMLParsing.text_style.size = page.Get<AndroidJavaObject>("popup_text_style").Get<AndroidJavaObject>("size").Get<int>("size");
//		pageYMLParsing.text_style.size_coordspace = page.Get<AndroidJavaObject>("popup_text_style").Get<AndroidJavaObject>("size").Get<AndroidJavaObject>("coordspase").Call<string>("name");
//		float [] fill_color = page.Get<AndroidJavaObject>("popup_text_style").Get<AndroidJavaObject>("fill_color").Get<float[]>("rgb");
//		pageYMLParsing.text_style.fill_color = new Vector3(fill_color[0],fill_color[1],fill_color[2]);
//		float [] stroke_color = page.Get<AndroidJavaObject>("popup_text_style").Get<AndroidJavaObject>("stroke_color").Get<float[]>("rgb");
//		pageYMLParsing.text_style.stroke_color = new Vector3(stroke_color[0],stroke_color[1],stroke_color[2]);
//		
//		pageYMLParsing.text_style.stroke_width = page.Get<AndroidJavaObject>("popup_text_style").Get<AndroidJavaObject>("stroke_width").Get<int>("size");
//		pageYMLParsing.text_style.stroke_width_coordspace = page.Get<AndroidJavaObject>("popup_text_style").Get<AndroidJavaObject>("stroke_width").Get<AndroidJavaObject>("coordspase").Call<string>("name");
		
		
		//pageYMLParsing.highlight_text_style.typeface
		
		//pageYMLParsing.karaoke_text_style.typeface
		
		//pageYMLParsing.karaoke_animation
		
		//text_block_text_alignment
	
		// popup_text_words:
		print(" cross stage 1");
		print(" cross stage 2");
		if(page.Get<AndroidJavaObject>("popup_text_words").Call<AndroidJavaObject>("keySet").Call<int>("size") > 0){
			
		using (AndroidJavaObject popupTextWordsMap = page.Get<AndroidJavaObject>("popup_text_words")){//Map<String,Color>
			
		pageYMLParsing.popup_text_words_str = popupTextWordsMap.Call<AndroidJavaObject>("keySet").Call<string []>("toArray");//OK
		//print(" cross stage 3"+pageYMLParsing.popup_text_words_str.Length);
		pageYMLParsing.popup_text_words_RGB = new Vector3[pageYMLParsing.popup_text_words_str.Length];
		print(" cross stage 4");
		
		valueArray = popupTextWordsMap.Call<AndroidJavaObject>("values").Call<AndroidJavaObject []>("toArray");//OK
		popupTextWordsMap.Dispose();
		}
		print(" cross stage 5");
		using (AndroidJavaObject  bookDefaultSettings = obj_Activity.Get<AndroidJavaObject>("bookConfig").Get<AndroidJavaObject>("book").Get<AndroidJavaObject>("defaults")){
		print(" cross stage 6");
		pageYMLParsing.popup_text_words_Key_Path = new string[pageYMLParsing.popup_text_words_str.Length];
		for(int i=0;i<pageYMLParsing.popup_text_words_str.Length;i++)
		{	
							AndroidJNI.NewGlobalRef(valueArray[i].GetRawObject());
			print(" cross stage 7 " +pageYMLParsing.popup_text_words_str[i]);
					//popup_text_words_Key.Add(keyArray[i]);
					float [] floatColor = valueArray[i].Get<float[]>("rgb"); // color array
			print(" cross stage 8");
					pageYMLParsing.popup_text_words_RGB[i] = (new Vector3(floatColor[0],floatColor[1],floatColor[2]));
			print(" cross stage 9"+pageYMLParsing.popup_text_words_RGB[i]);
					pageYMLParsing.popup_text_words_Key_Path[i] = (bookDefaultSettings.Get<AndroidJavaObject>("word_to_audio_mapping").Call<string>("get",pageYMLParsing.popup_text_words_str[i]));
		    	print(" cross stage 10 "+pageYMLParsing.popup_text_words_Key_Path[i]);
							AndroidJNI.DeleteGlobalRef(valueArray[i].GetRawObject());
							valueArray[i].Dispose();
		}
				print(" cross stage 12");

		//valueArray = null;
		bookDefaultSettings.Dispose();			
//		bookDefaultSettings = null;
		//popupTextWordsMap = null;
		}
}
				print(" cross stage 14");

		//phase starts here
		int numberOfPhases = page.Get<AndroidJavaObject>("phases").Call<int>("size");//Phase Size
		if(numberOfPhases > 0)
		{
			
			//int phasesArrayIndex = 0;
			pageYMLParsing.phases = new Phases[numberOfPhases];
			phases = page.Get<AndroidJavaObject>("phases").Call<AndroidJavaObject []>("toArray") ;
			print(pageArrayIndex+" cross stage 15 "+pageYMLParsing.phases.Length);
			for(int phasesArrayIndex = 0;phasesArrayIndex< numberOfPhases;phasesArrayIndex++)
			{
				AndroidJNI.NewGlobalRef(phases[phasesArrayIndex].GetRawObject());
				pageYMLParsing.phases[phasesArrayIndex] = getPhasesData(phases[phasesArrayIndex]);
				AndroidJNI.DeleteGlobalRef(phases[phasesArrayIndex].GetRawObject());
				phases[phasesArrayIndex].Dispose();
			}
		//	phases = null;
					
					
		}//phases ends here
		 print("cross till here "+pageArrayIndex);
			}catch(Exception exception){
										print("Exception pageYMLParsing: "+exception);
			}
			obj_Activity.Dispose();
		
	}
		
		print("Thread pop local reference: "+AndroidJNI.PopLocalFrame(IntPtr.Zero));
		
		/*
		int detachThread = AndroidJNI.DetachCurrentThread();
		if( detachThread == 0){
			print("AndroidJNI thread detachThread successfully");
		}else{
			print("thread started detachThread unsuccessful");
		}
		*/
		return pageYMLParsing;
}
	public Phases getPhasesData (AndroidJavaObject javaPhases) {
		Phases phase = new Phases();
		try{
			phase.phases_id =javaPhases.Get<string>("id"); 
				print(" cross stage 16 "+phase.phases_id);
				phase.position = new Vector2(javaPhases.Get<AndroidJavaObject>("position").Get<int>("x"),javaPhases.Get<AndroidJavaObject>("position").Get<int>("y"));
				print(" cross stage 17 "+phase.position);
				phase.position_coordspace =javaPhases.Get<AndroidJavaObject>("position").Get<AndroidJavaObject>("coordspase").Call<string>("name");
				print(" cross stage 18 "+phase.position_coordspace );
				phase.dimensions = new Vector2(javaPhases.Get<AndroidJavaObject>("dimensions").Get<int>("x"),javaPhases.Get<AndroidJavaObject>("dimensions").Get<int>("y"));
				print(" cross stage 19 "+phase.dimensions);
				phase.dimensions_coordspace =javaPhases.Get<AndroidJavaObject>("dimensions").Get<AndroidJavaObject>("coordspase").Call<string>("name");
				print(" cross stage 20 "+phase.dimensions_coordspace);
				phase.thumbnail_image =javaPhases.Get<string>("thumbnail_image");
				print(" cross stage 21 "+phase.thumbnail_image);
				try{//buttons starts here
							int buttonsArrayLength =javaPhases.Get<AndroidJavaObject>("buttons").Get<int>("size") ;
					print(" cross stage 22 "+buttonsArrayLength);
							if(buttonsArrayLength>0){
										AndroidJavaObject [] buttons =javaPhases.Get<AndroidJavaObject>("buttons").Call<AndroidJavaObject []>("toArray");
							                phase.buttons = new Button[buttonsArrayLength];
										   // int buttonsArrayIndex = 0;
											for(int buttonsArrayIndex =0;buttonsArrayIndex < buttonsArrayLength ;buttonsArrayIndex++)
											{
											AndroidJNI.NewGlobalRef(buttons[buttonsArrayIndex].GetRawObject());
											phase.buttons[buttonsArrayIndex] = getButtonData(buttons[buttonsArrayIndex]);
											AndroidJNI.DeleteGlobalRef(buttons[buttonsArrayIndex].GetRawObject());
											buttons[buttonsArrayIndex].Dispose();
											}
							            		// buttons = null;
					
										}
									
								}catch(Exception exception){
									print("Exception PageClass buttons: "+exception);
								}
				//buttons ends here
				
				
				//text blocks starts here
				int textBlockArrayLength =javaPhases.Get<AndroidJavaObject>("text_blocks").Call<int>("size");
				
				
				print("cross stage 23 "+textBlockArrayLength);
				if(textBlockArrayLength>0){
					phase.text_blocks = new TextBlock[textBlockArrayLength];
					textBlocks =javaPhases.Get<AndroidJavaObject>("text_blocks").Call<AndroidJavaObject []>("toArray");//TextBlock Array
					int textBlocksArrayIndex =0;
						
					
					for(textBlocksArrayIndex =0;textBlocksArrayIndex<textBlockArrayLength;textBlocksArrayIndex++){		
					//phase.text_blocks[textBlocksArrayIndex].rayIndex].Get<AndroidJavaObject>("text_blocks").Call<AndroidJavaObject []>("toArray");//TextBlock Array
					//int textBlocksArrayIndex =0;
					AndroidJNI.NewGlobalRef(textBlocks[textBlocksArrayIndex].GetRawObject());
					phase.text_blocks[textBlocksArrayIndex] = getTextBlockData(textBlocks[textBlocksArrayIndex]);			
					AndroidJNI.DeleteGlobalRef(textBlocks[textBlocksArrayIndex].GetRawObject());
					textBlocks[textBlocksArrayIndex].Dispose();
					}
			//	textBlocks = null;
				
			}
				
					//text blocks Ends here
		}catch(Exception exception){
									print("Exception PageClass phase: "+exception);
								}
		
		return phase;
	}
	
	
	public TextBlock getTextBlockData (AndroidJavaObject javaTextBlock) {
					TextBlock textBlock = new TextBlock();
		try{
					textBlock.position_coordspace = javaTextBlock.Get<AndroidJavaObject>("position").Get<AndroidJavaObject>("coordspase").Call<string>("name");
					textBlock.position = new Vector2(javaTextBlock.Get<AndroidJavaObject>("position").Get<int>("x"),javaTextBlock.Get<AndroidJavaObject>("position").Get<int>("y"));//OK
					textBlock.anchor_point_coordspace = javaTextBlock.Get<AndroidJavaObject>("anchor_point").Get<AndroidJavaObject>("coordspase").Call<string>("name");
					textBlock.anchor_point = new Vector2(javaTextBlock.Get<AndroidJavaObject>("anchor_point").Get<int>("x"),javaTextBlock.Get<AndroidJavaObject>("anchor_point").Get<int>("y"));//OK
								
					textBlock.text_lines = javaTextBlock.Get<AndroidJavaObject>("text_lines").Call<string []>("toArray");//String arrray Ok
							
					
					//text word groups starts here		
					int textWordGroupsLength = javaTextBlock.Get<AndroidJavaObject>("text_word_groups").Call<int>("size");
					
					print("cross stage 24 "+textWordGroupsLength);	
						
					if(textWordGroupsLength>0){	
							
					textWordGroups =javaTextBlock.Get<AndroidJavaObject>("text_word_groups").Call<AndroidJavaObject []>("toArray");//Integer type OK
		            
					textBlock.text_word_groups = new int[textWordGroupsLength];
							print("cross stage 25 "+textBlock.text_word_groups.Length);
							
							//int textWordGroupIndex = 0;//textWordGroups[textWordGroupIndex].Call<int>("intValue");	
											for(int textWordGroupIndex =0;textWordGroupIndex<textWordGroupsLength;textWordGroupIndex++){
					AndroidJNI.NewGlobalRef(textWordGroups[textWordGroupIndex].GetRawObject());
												textBlock.text_word_groups[textWordGroupIndex] = textWordGroups[textWordGroupIndex].Call<int>("intValue");
								                print(" cross = "+textBlock.text_word_groups[textWordGroupIndex]);
					AndroidJNI.DeleteGlobalRef(textWordGroups[textWordGroupIndex].GetRawObject());
					textWordGroups[textWordGroupIndex].Dispose();
											}
											textWordGroups = null;
				
					}
						
		
		
		
		//audio path araray pageYMLParsing.text_line_audioPath
				//int textBlockArrayLength = phases[phasesArrayIndex].Get<AndroidJavaObject>("text_blocks").Call<int>("size");
				//if(textBlockArrayLength>0){
				//for(int textBlocksArrayIndex = 0;textBlocksArrayIndex<textBlockArrayLength;textBlocksArrayIndex++){
		
		
						//string []str = getTextLineToStringArray(textBlock.text_lines);
					    //str =  textBlock.text_lines[0].Split(new char[]{' '});
						
				textBlock.text_line_StrArr = getTextWordGroupedArray(textBlock);//new string[textBlock.text_word_groups.Length];
			
		print ("cross  text_line_StrArr.Length "+textBlock.text_line_StrArr.Length);
						
				textBlock.text_line_audioPath = new string[textBlock.text_line_StrArr.Length];
				
				using (AndroidJavaObject  bookDefaultSettings = obj_Activity.Get<AndroidJavaObject>("book").Get<AndroidJavaObject>("defaults")){
				
				for(int i=0;i<textBlock.text_line_StrArr.Length;i++)
					     {
						    string temp = textBlock.text_line_StrArr[i];
						    if(textBlock.text_word_groups[i] > 1)
						    temp = Regex.Replace(temp, @"[^a-zA-Z]"," ");
						    else
							temp = Regex.Replace(temp, @"[^a-zA-Z]","");
						    textBlock.text_line_audioPath[i] = (bookDefaultSettings.Get<AndroidJavaObject>("word_to_audio_mapping").Call<string>("get",temp));
							print(textBlock.text_line_audioPath[i]+" cross text_line_StrArr[i] = "+temp);
					     }
				bookDefaultSettings.Dispose();
		}
				//	}
				//}	
				
				// audio path array pageYMLParsing.text_line_audioPath
					
						
						//text word group ends here				
							
										//text karaoke timing starts here
					int textKaraokeTimingsArrayLength =  javaTextBlock.Get<AndroidJavaObject>("text_karaoke_timings").Call<int>("size");
								
						print("cross stage 25 "+textKaraokeTimingsArrayLength);	
						if(textKaraokeTimingsArrayLength>0){
						textBlock.text_karaoke_timings = new Vector2[textKaraokeTimingsArrayLength];
						int textKaraokeTimingsIndex = 0;
					textKaraokeTimings = javaTextBlock.Get<AndroidJavaObject>("text_karaoke_timings").Call<AndroidJavaObject []>("toArray");//Tuple type OK
				
						for(textKaraokeTimingsIndex =0;textKaraokeTimingsIndex<textKaraokeTimingsArrayLength;textKaraokeTimingsIndex++){
					AndroidJNI.NewGlobalRef(textKaraokeTimings[textKaraokeTimingsIndex].GetRawObject());
											textBlock.text_karaoke_timings[textKaraokeTimingsIndex] = (new Vector2(textKaraokeTimings[textKaraokeTimingsIndex].Get<AndroidJavaObject>("x").Call<float>("floatValue"),textKaraokeTimings[textKaraokeTimingsIndex].Get<AndroidJavaObject>("y").Call<float>("floatValue")));
												AndroidJNI.DeleteGlobalRef(textKaraokeTimings[textKaraokeTimingsIndex].GetRawObject());	
					textKaraokeTimings[textKaraokeTimingsIndex].Dispose();
											}
											textKaraokeTimings = null;
										}
								
										//text karaoke timing ends here
										
										
					textBlock.text_audio = javaTextBlock.Get<string>("text_audio"); 
											
					
				
					 /*
					AndroidJavaObject textPerWordGroupAudio = javaTextBlock.Get<AndroidJavaObject>("text_per_word_group_audio");//Map<Integer,String>
								
					AndroidJavaObject textStyle = javaTextBlock.Get<AndroidJavaObject>("text_style");
					AndroidJavaObject highlightTextStyle = javaTextBlock.Get<AndroidJavaObject>("highlight_text_style");
					AndroidJavaObject karaokeTextStyle = javaTextBlock.Get<AndroidJavaObject>("karaoke_text_style");
								
								int karaokeAnimationLength = javaTextBlock.Get<AndroidJavaObject>("karaoke_animation").Call<int>("size");
								stringToEdit2 = stringToEdit2+"\n karaokeAnimationLength: "+karaokeAnimationLength;
								if(karaokeAnimationLength>0){
									AndroidJavaObject [] karaokeAnimation = javaTextBlock.Get<AndroidJavaObject>("karaoke_animation").Call<AndroidJavaObject []>("toArray");//is in slight doubt
								}// till here everything is fine
					AndroidJavaObject textAlignment = javaTextBlock.Get<AndroidJavaObject>("text_alignment");
					
					bool canCustomizeText = javaTextBlock.Get<bool>("can_customize_text");
					bool canCustomizeAudio = javaTextBlock.Get<bool>("can_customize_audio");
								stringToEdit2 = "\n"+stringToEdit2+"  canCustomizeAudio: "+canCustomizeAudio;
								*/
					/* 
					 * //Can't test this block in the available book_config.yaml
					
					}
					
					*/
					//canCustomizeText+" boolValues " +canCustomizeAudio;
		}catch(Exception exception){
									print("Exception PageClass textBlock: "+exception);
								}
		return textBlock;
	}
	
	public Button getButtonData (AndroidJavaObject javaButton) {
	Button button = new Button();
			button.button_id = javaButton.Get<string>("id");//Ok
			button.position = new Vector2(javaButton.Get<AndroidJavaObject>("position").Get<int>("x"),javaButton.Get<AndroidJavaObject>("position").Get<int>("y"));//OKOk
			button.position_coordspace = javaButton.Get<AndroidJavaObject>("position").Get<AndroidJavaObject>("coordspase").Call<string>("name");
            button.normal_image = javaButton.Get<string>("normal_image");//Ok
			
            button.pressed_image = javaButton.Get<string>("pressed_image");//Ok
			button.action = javaButton.Get<AndroidJavaObject>("action").Call<string>("name");//Enum type//Ok  
				
		return button;						
	}
	
	
	public string [] getTextWordGroupedArray(TextBlock textBlock){
		try{
			
				string [] str = getTextLineToStringArray(textBlock.text_lines);
//			foreach(string str1 in str){
//		print("cross getTextWordGroupedArray str: "+str1);
//			}
					int groupIndex =0;
		textBlock.text_line_StrArr = new string [textBlock.text_word_groups.Length];
					for(int i=0;i<str.Length;i++)    
					{
				
								if(textBlock.text_word_groups[groupIndex] >1)
								{    
									//print("cross getTextWordGroupedArray if: "+i);
									string temp = "";
								    for(int j=0;j<textBlock.text_word_groups[groupIndex];j++)
									{
										temp += str[i+j]+" ";
									}
							        temp = temp.Trim();
									i = i+ (textBlock.text_word_groups[groupIndex]-1);
									textBlock.text_line_StrArr[groupIndex] = temp;
							        groupIndex++;
								}
						        else
						        {
									//print("cross getTextWordGroupedArray else: "+i);
									textBlock.text_line_StrArr[groupIndex] = str[i];
									groupIndex++;
						        }
					}
			}catch(Exception exception){
									print("Exception PageClass textBlock.text_line_StrArr: "+exception);
									//print("Exception PageClass textBlock.text_line_StrArr: "+textBlock.text_lines[0]+" "+textBlock.text_word_groups.Length);
								}
		return textBlock.text_line_StrArr;
		
	}
	
	
	public string [] getTextLineToStringArray(string [] textLine){
		
		string [] tempStrArray = new string[]{};
		try{
//		print("cross getTextLineToStringArray tempStrArray:L "+textLine.Length);
		
		for(int textLineIndex = 0;textLineIndex<textLine.Length;textLineIndex++){
				
		string[] anotherTempStringArray = textLine[textLineIndex].Split(new char[]{' '});
		string[] mergeArray = new string[tempStrArray.Length + anotherTempStringArray.Length];
		Array.Copy(tempStrArray, mergeArray, tempStrArray.Length);
		Array.Copy(anotherTempStringArray, 0, mergeArray, tempStrArray.Length, anotherTempStringArray.Length);
			
			tempStrArray = mergeArray;
			
			
			mergeArray = null;
			anotherTempStringArray = null;
		}
//		for(int i =0; i<tempStrArray.Length;i++){
//				print("cross getTextLineToStringArray tempStrArray: "+tempStrArray[i]);
//			}
			}catch(Exception exception){
									print("Exception PageClass getTextLineToStringArray: "+textLine+" <length: "+exception);
								}
		return tempStrArray;
			
	}
	
	
	
}


;

I hope you guys have any solution for this.
Thanks in advance.