Friday, 13 October 2017

android - App crashes when trying to fullscreen activity

itemprop="text">

Hi I'm using the code below to hide
actionbar and fullscreen my
activity




android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"


But
with this code I get runtime error and app just crashes anyone know whats the
problem?



Logcat:





E/AndroidRuntime(1081): FATAL EXCEPTION:
main

E/AndroidRuntime(1081): Process: com.example.directmate, PID:
1081
E/AndroidRuntime(1081): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.example.directmate/com.example.directmate.MainActivity}:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant)
with this activity.
E/AndroidRuntime(1081): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
E/AndroidRuntime(1081):
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
E/AndroidRuntime(1081):
at
android.app.ActivityThread.access$800(ActivityThread.java:135)
E/AndroidRuntime(1081):
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/AndroidRuntime(1081):
at
android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(1081):
at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(1081): at
android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime(1081):
at java.lang.reflect.Method.invokeNative(Native
Method)

E/AndroidRuntime(1081): at
java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(1081): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime(1081):
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime(1081):
at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(1081):
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or
descendant) with this activity.
E/AndroidRuntime(1081): at
android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
E/AndroidRuntime(1081):
at
android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
E/AndroidRuntime(1081):
at
android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
E/AndroidRuntime(1081):
at
com.example.directmate.MainActivity.onCreate(MainActivity.java:22)
E/AndroidRuntime(1081):
at
android.app.Activity.performCreate(Activity.java:5231)

E/AndroidRuntime(1081):
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime(1081):
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
E/AndroidRuntime(1081):
... 11 more

itemprop="text">
class="normal">Answer



It's
probably related to your activities extend part, with this code you added to your
manifest you need to extend Activity instead of
ActionbarActivity


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...