how to view source of native methods in Android Studio - android

I am in Android Studio diving into the source code of Android. As I dig deeper, I get to a method of the form, say, native_setup(name, nameIsType, encoder);. When I click through, all I get is
private native final void native_setup(
#NonNull String name, boolean nameIsType, boolean encoder);
I want to see the source of that native method right from inside Android Studio. How might I do that?

You basically need to attach GDB to your app Bedug thread and set your native source path. You can find more info here :
https://developer.oculus.com/documentation/mobilesdk/latest/concepts/mobile-studio-debug/
https://visualgdb.com/tutorials/android/astudio/
https://github.com/mapbox/mapbox-gl-native/wiki/Android-debugging-with-remote-GDB

Related

Android status bar show in Unty

I'm triyng to show the status bar in an Android phone using Unity. I have try this code:
void Start() {
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
But an error appear;
Assets/Scenes/Control/control.cs(15,34): error CS0103: The name 'WindowManager' does not exist in the current context
Does I need to call or import another package? Some could help me with this detail. Thanks in advance.
You cannot use Android Java functions directly in Unity. You can only use whats available in Unity C Sharp. Unity doesn’t understand the method. Suggested workaround, use a ‘Slider’ UI element and manipulate it in a custom c sharp script. Complicated workaround create a custom Unity Plugin which calls the native Android method (possible but complex).

Show image in TImage dynamically (at run time) without opendialog in c++ builder xe8

I want to show image (png,jpg etc) in dynamically created (as per requirement and fully through coding) TImage component, at runtime in C++ builder xe8 (not delphi). But I dont want to use opendialogbox (suggested in many web sites). I want to run this app on my android device. I tried to use LoadFromFile(), it crashes the app on android, but when I run this on windows, its running smoothly. I am just a beginner to c++ builder. So guys pls help. Thanx in advance for any kind of help.Here is what I did.
void __fastcall TForm1::TForm1(TComponent* Owner)
{
TImage* img = new TImage(this);
img->Parent = this;
img->Bitmap->LoadFromFile("D:\\res\\profile.png");
}
Did you see what is the error?
If you run the program with the provided by you code I assume the error would be that the file is not found, because there is no such directory "D:\" in android.
One way to set the path is to write a static path which points to your image. For example : "/storage/sdcard0/DCIM/Camera/MyImage.jpg";
The second way is to include the <System.IOUtils.hpp> header and to use some built-in functions like:
System::Ioutils::TPath::GetPicturesPath();
System::Ioutils::TPath::GetAlarmsPath();
You can check them out, they might be useful.

Android java.lang.VerifyError with exp4j Libraries

I tried to make my own small calculator, but I don't want to make all the business logic by myself. So I tried to use the javax.script since I heard that the javax.script needs a real JVM and is a JavaScriptParser. Then, I searched for other libraries with the functions I needed and found the project "exp4j". First, I made a small normal Java Project with JDK 1.7, and yes, it works with the source code:
public static void main(String[] args) throws UnknownFunctionException, UnparsableExpressionException {
ExpressionBuilder builder=new ExpressionBuilder("34*2");
Calculable calc=builder.build();
System.out.println(calc.calculate());
}
Then, I tried the same code in my model (MVC Pattern) of my calculator:
public void berechnen() throws UnknownFunctionException, UnparsableExpressionException {
ExpressionBuilder builder=new ExpressionBuilder("34*2");
Calculable calc=builder.build();
setErgebnis(calc.calculate());
}
But every time I got the same exception:
"AndroidRuntime(630): java.lang.VerifyError",
after I started the app. I can't click on the button that runs the method berechnen() because the app crashes after I start it.
I'm confused why my program doesn't work. When I delete all imports of exp4j and delete the source for the calculation, my calculator works fine.
My only idea is that the exp4j libaries is using a class or method that does not exist in Android.
Thank you.
You may have include jars twice, check once in libs folder and libraries in properties, I have faced same in the past What you need to do is to
Remove that in the libraries and paste freshly in your res/lib folder of android application project and then clear your project

How to import a SpriteFont into MonoGame

I'm porting a simple tetris-like XNA app to Android, using Mono For Android and MonoGame; I have followed the suggested steps in this link and so far, everything compiles well, and no relevant warnings fire up. However, upon loading the contents, a null parameter exception breaks the program at the point below in my program:
protected override void LoadContent() {
// ...
_font = Content.Load<Microsoft.Xna.Framework.Graphics.SpriteFont>("SpriteFont1");
// ...
}
The content root directory is set in the game constructor class:
public Game2 (){
Content.RootDirectory = "Content";
Content.RootDirectory = "Assets/Content"; // TEST.
//...}
And I have tried several combinations, all to no avail.
I have also tried setting the xnb files as Content as well as Android Assets in the Build Action property; having the linked, copied always, copied only if newer... etc.
Either way, my problem is that I don't really understand WHY and HOW should I do this. I'm rather new to the platform and to XNA as well, so this may very well be a newbie question, but the truth is after several hours banging my head and fists against the monitor/keyboard I feel stuck and need your help.
I have a library that supports variable-width fonts (generated by BMFont) on MonoGame. Unfortunately it is a renderer and so has other code around it. However, the basic idea is very simple. You can take a look at the loader here and the mesh builder (given a string) here. This builder supports fonts that spread characters across multiple pages, too.
Hope this helps!
MonoGame (2.5.1) throws NotImplementedException in ContentManager.Load for SpriteFont type. Have the same not resolved problem. I'm trying not to use DrawString.
For loading textures in Win32 application I use:
Content.RootDirectory = #"../../Content";
var sampleTexture = Content.Load<Texture2D>("Sample.png");
You even must not add it to solution.
For Andoind (MonoDroid) application you must add "Content" folder to your solution and set "Andtoid Asset" in "Sample.png" properties.
Content.RootDirectory = "Content";
var sampleTexture = Content.Load<Texture2D>("Sample.png");
See also:
http://monogame.codeplex.com/discussions/360468
http://monogame.codeplex.com/discussions/267900

Text Selection In Android Webview

to select text in web view below code is working fine
KeyEvent shiftPressEvent = new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0)
shiftPressEvent.dispatch(webView);
but that dispatch method is deprecated. so instead of that i like to use this
public final boolean dispatch (KeyEvent.Callback receiver, KeyEvent.DispatcherState state, Object target)
give me an idea from the above function to select text.
I got web view selections working in 2.2 - 4.0.3 using a javascript interface that gets all touches passed to it. The solution seems to work pretty well and I've put an example project on github. The github project includes the necessary js in the assets folder as well as a test page and web view that loads the test page and implements all necessary methods to handle the selection. The link to the github project is https://github.com/btate/BTAndroidWebViewSelection. Have at it.

Categories

Resources