- Home /
Android Plugin calling a method error.
Hi! I'm trying to call a method from unity (c#) to android API. I've extended the unity player activity like this:
package com.example.name;
import com.unity3d.player.UnityPlayerActivity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
public class AlertActivity extends UnityPlayerActivity {
final Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("OverrideActivity", "OnCreate called!");
}
public void showMsg() {
Log.d("OverrideActivity", "ShowMsg called!");
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
alertDialogBuilder.setTitle("Hello unity!");
alertDialogBuilder.setMessage("Yep, I'm android!").setCancelable(true);
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
I've generated the Jar library and put it in Plugins/Android folder. My Bundle identifier name is ok. I've changed the manifest document to use my activity instead of the unity's default one. (I'm sure that's mine which is actually using because it's showed in eclipse logs) But when I try to call the method (showMsg)the apps closes with:
VM aborting Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 17136 (UnityMain)
this is the c# code I'm using to call the method:
AndroidJavaClass jc = new AndroidJavaClass("com.example.name.AlertActivity");
jc.Call("showMsg");
What I am doing wrong??!
Your answer
![](https://koobas.hobune.stream/wayback/20220613095810im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Editing Android Plugins 0 Answers
Transparent navigation bar 0 Answers
Plugin for Facebook Native Ads 0 Answers
targetSdk is considered missing when I already put it in my custom AndroidManifest.xml 2 Answers