0

Edit

I found out, that the requirements for showing a notification consist of setting a content-title, a context-text and a small icon. The last of which I do not do. Unfortunately, I don't know, how to provide a small icon especially in unity.

Original Question

I'm currently trying to show a notification from a unity-instance via android. I want to show the notification, when the user enters a specific gps-area. Thus, the script should run, when the app is paused. That's why I want to use the android-functionality.

With this code, I currently try to show the notification manually:

    public void createNotification(){
        NotificationManagerCompat nManager = NotificationManagerCompat.from(curContext);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(curContext, CHANNEL_ID)
                .setContentTitle("Stuff")
                .setContentText("MoreStuff")
                .setPriority(NotificationCompat.PRIORITY_DEFAULT);



        nManager.notify(1551, builder.build());
    }

The context is stored in a static variable and is set, when calling the method.

The function is called in C# with:

PluginInstance.Call("createNotification");

The PluginInstance works, the function can be called, but I get the error:

AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationManagerCompat
Lenny Will
  • 549
  • 1
  • 4
  • 11

1 Answers1

0

I found the solution for my problem: I used the Unity Android Jar-Resolver in which I provided the *Dependencies.xml (Where the * presents the Name of my project). In the *Dependenices.xml I specified: <androidPackage spec="androidx.appcompat:appcompat:1.1.0"> and run through the steps, provided in the Tutorial of the Resolver.

Afterwards, multiple dependencies appeared in my /Assets/Plugin/Android-Folder, which were successfully transferred to the app, when building it.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Lenny Will
  • 549
  • 1
  • 4
  • 11