- Home /
Calling an AppCompatActivity, You need to use a Theme.AppCompat theme (or descendant) with this activity
I'm trying to call a Java Class from Unity which extends AppCompatActivity, I'm getting the error: you need to use a theme.appcompat theme (or descendant) with this activity. However I am using this as you can see below.
AndroidManifest.xml (Android Studio):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MyPackage.ProjectName">
<application android:theme="@style/Theme.AppCompat.Light">
<activity
android:name=".MyActivity"
android:theme="@style/Theme.AppCompat.Light">
</activity>
</application>
</manifest>
AndroidManifest.xml (Unity):
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:theme="@style/Theme.AppCompat.Light"
android:label="@string/app_name" android:screenOrientation="fullSensor"
android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
MyActivity.java:
package com.MyPackage.Project;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public void StartActivity(Activity activity)
{
Intent intent = new Intent(activity, MyActivity.class)
activity.startActivity(intent);
}
}
CallActivity.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CallActivity : MonoBehaviour
{
void Start()
{
AndroidJavaObject ajo = new AndroidJavaObject("com.MyPackage.Project.MyActivity");
ajo.Call("StartActivity", ActivityClass.currentActivity);
}
}
ActivityClass.currentActivity is Unity's currentActivity. Either way I am getting the error about the AppCompat theme and I have no idea why. I hope it's even possible to call an AppCompatActivity from Unity cause I can't find anything about it. Hopefull someone here knows something because it would really help me out.
Good thing literally nobody knows the answer :), I initially used AppCompatActivity for my ActionBar but I got it to work in a normal Activity ins$$anonymous$$d, still gotta get it to work inside a Unity Activity. Would still like to know how to call an AppCompatActivity from Unity so if anyone knows it then please answer.
Your answer
![](https://koobas.hobune.stream/wayback/20220612150527im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
kill unity activity before launching new android activity 0 Answers
Android plugin to extend UnityPlayerActivity but not use Unity project's package name 0 Answers
Restarting UnityPlayer inside of Android activity 0 Answers
(Android) mUnityPlayers SurfaceView Access 2 Answers
Now that Unity 4.1.2 broke the Android plugin examples, what do you use to learn them? 1 Answer