I'm trying to create a transparent activity so I give the activity the following style:
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
I don't know why but it crashes the app.
Any idea why?
EDIT: this is my logcat, i'm a newbie so I don't know much about debugging it.
05-14 06:25:08.919 1218-1307/system_process I/ActivityManager﹕ START u0 {cmp=com.myapp.enterprise/.GreenViewActivity} from uid 10057 on display 0
05-14 06:25:08.924 1218-1265/system_process W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
05-14 06:25:08.959 6744-6744/com.myapp.enterprise D/AndroidRuntime﹕ Shutting down VM
05-14 06:25:08.959 6744-6744/com.myapp.enterprise E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myapp.enterprise, PID: 6744
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.enterprise/com.myapp.enterprise.GreenViewActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at com.myapp.enterprise.GreenViewActivity.onCreate(GreenViewActivity.java:13)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-14 06:25:08.965 1218-7949/system_process W/ActivityManager﹕ Force finishing activity 1 com.myapp.enterprise/.GreenViewActivity
05-14 06:25:08.978 1218-7949/system_process W/ActivityManager﹕ Force finishing activity 2 com.myapp.enterprise/.NoteActivity
05-14 06:25:09.083 1218-2572/system_process I/OpenGLRenderer﹕ Initialized EGL, version 1.4
05-14 06:25:09.110 1218-2572/system_process W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-14 06:25:09.110 1218-2572/system_process W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x9d932880, error=EGL_SUCCESS
05-14 06:25:09.490 1218-1236/system_process W/ActivityManager﹕ Activity pause timeout for ActivityRecord{5ebb3cd u0 com.myapp.enterprise/.GreenViewActivity t546 f}
You require to use parent="#style/Theme.AppCompat" as parent instead of current parent="android:Theme"
just Use this theme in your activity in Menifest xml file to create Transparent Activity
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
if you are extending your activity from AppCompactActivity or ActionBarActivity the you must your parent theme
<style name="Theme.Transparent" parent="#style/Theme.AppCompat.Light.DarkActionBar">
for whole application or for just activty
Related
I am following a tutorial on how to make a launcher but for some reason when I add this line of code to my main activity with in the manifest the app crashes saying that my app has stopped
android:theme="#android:style/Theme.Holo.Wallpaper.NoTitleBar"
10-18 15:04:25.245 18122-18122/com.example.harrops.h20droidlauncher E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.harrops.h20droidlauncher, PID: 18122
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.harrops.h20droidlauncher/com.example.harrops.h20droidlauncher.HomeLayout}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5598)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:309)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:278)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:252)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.harrops.h20droidlauncher.HomeLayout.onCreate(HomeLayout.java:13)
at android.app.Activity.performCreate(Activity.java:5459)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5598)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
if I remove the line of code the app runs just fine.
Any help would be great. Thanks as always in advance.
To change the Background use:
android:background=" "
You selected a wallpaper.
Try this instead
android:background="#b6db49">
Below you have said that you want to use the theme. So you have to go in the manifest and edit the theme there which is
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Wallpaper.NoTitleBar">
If You've begun Your project in Android Studio by default main activity extends
ActionBarActivity which requires the AppCompat theme. Change the Java inheritance from ActionBarActivity to Activity and leave the theme in the manifest as it is. Or use AppCompat theme.
This is the theme i wanted to use "android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" in my app but for some reasonit keeps crashing my app.Can anyone point out the errors?.I changed the theme in values folder too it didn't work .
minSdkVersion 17
targetSdkVersion 21
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="crystalball.com.example.android.crystlalball" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is logcat:
08-30 15:10:48.220 1969-1969/crystalball.com.example.android.crystlalball I/art﹕ Not late-enabling -Xcheck:jni (already on)
08-30 15:10:48.368 1969-1969/crystalball.com.example.android.crystlalball D/AndroidRuntime﹕ Shutting down VM
--------- beginning of crash
08-30 15:10:48.368 1969-1969/crystalball.com.example.android.crystlalball E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: crystalball.com.example.android.crystlalball, PID: 1969
java.lang.RuntimeException: Unable to start activity ComponentInfo{crystalball.com.example.android.crystlalball/crystalball.com.example.android.crystlalball.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:152)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:149)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at crystalball.com.example.android.crystlalball.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
device not found
Space at the end of your string is causing the problem. Please remove the space after Fullscreen.
After I Change package name there is an error occur like.
I am tryng to change package name. package name will be change but there is an error that service not register. and my application cant able to run properly. application cant able to destroy launcher activity.
06-26 16:45:19.806 27366-27366/my.instaupdate.otr.app.im E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: my.instaupdate.otr.app.im, PID: 27366
java.lang.RuntimeException: Unable to destroy activity {my.instaupdate.otr.app.im/my.instaupdate.otr.app.im.app.WelcomeActivity}: java.lang.IllegalArgumentException: Service not registered: my.instaupdate.cacheword.CacheWordActivityHandler#14403580
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3758)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3776)
at android.app.ActivityThread.access$1400(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.IllegalArgumentException: Service not registered: my.instaupdate.cacheword.CacheWordActivityHandler#14403580
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1033)
at android.app.ContextImpl.unbindService(ContextImpl.java:1936)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:550)
at my.instaupdate.otr.app.im.app.WelcomeActivity.onDestroy(WelcomeActivity.java:231)
at android.app.Activity.performDestroy(Activity.java:6132)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1163)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3745)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3776)
at android.app.ActivityThread.access$1400(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
this error about what???
I am developing an expandable list view application on which i want to add action bar.
It seems for action bar visibility I need to extend ActionBarActivity Class, but to run my Expandable list activity I should extend activity class.
So, I changed following code
from
public class Time extends Activity {
to
public class Time extends ActionBarActivity {
assuming following hierarchy
java.lang.Object
↳ android.content.Context
↳ android.content.ContextWrapper
↳ android.view.ContextThemeWrapper
↳ android.app.Activity
↳ android.support.v4.app.FragmentActivity
↳ android.support.v7.app.ActionBarActivity
But,when i run my application now i get null pointer exception at super.onCreate(savedInstanceState);
Please check log here:
12-19 00:10:48.995 14128-14128/sudharshanapps.clock E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: sudharshanapps.clock, PID: 14128
java.lang.RuntimeException: Unable to start activity ComponentInfo{sudharshanapps.clock/sudharshanapps.clock.Time}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at sudharshanapps.clock.Time.onCreate(Time.java:247)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Could you please suggest, what is missing here or any references or ideas where to look for.
Changed Manifest file from
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="Time across Globe"
android:theme="#style/AppTheme" >
to
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="Time across Globe"
android:theme="#style/Theme.AppCompat.Light" >
It solved the issue
i created a android project with blank activity created with fragment and with minSdkVersion 10 and targetSdkVersion 21 when i run my app on my devise nexus 4 android 5.0 the app crashed and i don't know why .
when i switch from ActionBarActivity to Activity the app work but i want create the app with ActionBarActivity .
and logcat give me this error Unable to start activity ComponentInfo{com.rhanem.android.forecast.app/com.rhanem.android.forecast.app.MainActivity}: java.lang.IllegalStateException: Activity has been destroyed
she give me this message in logcat
Process: com.rhanem.android.forecast.app, PID: 3644
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rhanem.android.forecast.app/com.rhanem.android.forecast.app.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at com.rhanem.android.sunshine.app.MainActivity.onCreate(MainActivity.java:20)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
please help my
In Manifest file specify Theme.AppCompat theme (or it's descendant) for your Activity.
android:theme="Theme.AppCompat"