I have spent a long time on forums looking at how to change the theme for my activities in android app development.
My main objective is to remove the title bar. But would still like to know how to change themes in general.
I have tried changing the theme using the GUI built into Android Studio... the theme changes in the preview, but when I run the app on my phone nothing changes.
So I figured I would change the theme using some xml code in the Manifest file.
What everyone seems to be doing is the following:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dennis.activeapp" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
<!-- HERE IS WHERE I SET THE THEME -->
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SecActivity"
android:label="#string/title_activity_sec" >
</activity>
<activity
android:name=".FirActivity"
android:label="#string/title_activity_fir" >
</activity>
</application>
</manifest>
The above is my code.
Now, when I try to run this on my phone the app crashes. The app opens for a fraction of a second and then closes.
If it is any help my phone is the Cubot S208. Since I have a feeling the problem might not be the code, as I followed directly what people have said in previous posts/forums.
The error message I receive in the ADB logs is the following:
ddms: null
java.lang.NullPointerException
at com.android.ddmlib.Client.read(Client.java:731)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:311)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
PropertyFetcher: AdbCommandRejectedException getting properties for device 0123456789ABCDEF: device unauthorized. Please check the confirmation dialog on your device.
PropertyFetcher: AdbCommandRejectedException getting properties for device 0123456789ABCDEF: device unauthorized. Please check the confirmation dialog on your device.
However I am certain that is the code below the comment (The theme) that is causing this issue. As without it I have no crash !
Related
The problem occurred overnight. One day, everything worked fine. I shut my computer down and started it back up on another day. However, without changing a thing, I tried to launch my App on the same virtual device I had before and somehow it wont launch because:
"Error running 'app'. Default Activity not found."
My manifest looks like this. I changed the package name and the two activities below (see comments below). The rest is exactly the same.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="MyPackageName">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait">
</activity>
<activity android:name=".AnotherActivity" />
<activity android:name=".OneMoreActivity">
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="364e8b3f6acfddf9ad32bed8c1503bb762b19cd5" />
</application>
</manifest>
And normally my app would just start with the Login Activity. However, now it does not. I tried to "Invalidate Caches / Restart". Nothing changed. I restarted AS multiple times. Still, nothing.
Then I tried to change the Launch Options. Current Option was set to "Default Activity". So I tried to change it to a specific one. Namely, the LoginActivity. But then it tells me:
"Error running 'app'. The Activity 'LoginActivity' is not declared in AndroidManifest.xml."
It tells me it's not declared, which it clearly is. Otherwise I wouldn't be able to choose it from the dropdown in the first place. I also tried to start on another Activity. "MainActivity". Still nothing.
What exactly am I doing wrong? Is there maybe a workaround where I can manually get the APK on my virtual device so that I can at least keep working?
Edit
I already tried deleting the .gradle-folder. Sadly this didn't work. I tried pushing it to git and cloning it again in another folder. That didn't work either.
Workaround
So far I've only been able to find a workaround:
Go to Run/Edit Configurations...
Go to General/Launch Options -> Launch: Nothing
Run as you normally would. Android Studio will build the project and install the application to your device, but won't launch it!
Launch your app manually on your device.
Go to Run/Attach Debugger to Android Process.
Choose your app.
Obviously, that's a little bit of a hassle and might make debugging the start of an app more difficult. So I'm still looking for an actual solution.
I've found the answer when I tried to look for a solution to another problem that randomly popped up out of nowhere.
Androidstudio wouldnt load any previews and put warnings in my layouts, because
One or more layouts are missing the layout_width or layout_height attributes.
One solution suggested in
the answer I found for that problem
was to delete all files in
C:\Users\UserName.AndroidStudio3.2\system\caches
Thats what I did and it solved both problems. Guess the developers have some fixing to do.
I've read up on forum posts about similar errors, but nothing I read works. It looks like my formatting is fine, but I keep getting the indicated error. I've tried refreshing the project and cleaning the project as well as restarting Eclipse entirely.
<manifest
... >
<application
... >
<activity
android:name="com.myNamespace.myPackage.MainActivity"
android:label="#string/app_name">
</activity>
</application>
</manifest>
In your manifest you must have forget to close one of the attribute. Check out your manifest file closely and make sure you have closed all the tags.
I also faced the same isssue but I found that it was coming because of copying and pasting the code in xml file.
Please try to type the code manually and see. Hope the error will not come.
try like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myNamespace.myPackage"
android:versionCode="12" android:versionName="2.2.0">
<uses-sdk android:minSdkVersion="3" />
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="false">
<activity android:name="com.myNamespace.myPackage.MainActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:label="#string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I had the same error until I figured out that the activity tag needs to open and close on the same line. It's not a written syntax but my error was gone when I wrote the whole tag in one line instead of on separate lines. You should try it like this:
<application>
<activity android:name=".MainActivity" android:label="#string/app_name"> </activity>
</application>
</manifest>
I develop in Eclipse on a Mac. When I copy items (both from within Code and/or from a webpage (like Stackoverflow or so) I often get this error. I believe that the copy/paste mechanism is not functioning completely well.
What I do to solve this error, is just typing the complete line (no copy/paste!), all over again.
When I have copied a block I see that the error moves to the next line, which you have to retype also.
Very time consuming and frustrating, but this really works!
i'm deploying an android application (Android 4.0.3) and when I press the home screen the application doesn't stay on the recent apps list. I've noticed that when I restart the application, it starts on the last screen i've navigated before press the home button. Anyone can help? Here is me Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/logo_home"
android:allowBackup="true">
<activity
android:name="com.test.activity.CommunicatorActivity"
android:launchMode="singleTop"
android:label="" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.test.activity.InputActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
<activity android:name="com.test.activity.SettingsActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
<activity android:name="com.test.activity.OutputActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
</application>
</manifest>
I'm going to go out on a limb and suggest that this is your problem:
android:label=""
In your root activity CommunicatorActivity you've set the label to be an empty string. This label is used to identify your app in the list of available apps and because it is empty, this may be causing it not to show up in the list of recent apps.
Remove android:excludeFromRecents="true" from your manifest
You should use
android:label="your app_name"
2 things
Ok, there isn't something obvious in your manifest that should prevent it from appearing in your recents list.
1. Wrong identification
It's not always straight forward to tell which task contains your activity, using the GUI.
One of the possibilities is that an activity from some other app is on top of your task making you believe that your activity isn't there. Since, clearly it resumes to the last screen.
I suggest you to remove the single top temporarily and check the same.
2. Launcher modification
Has the launcher you use the standard launcher? Has the launcher or some other app modified the presentation or behavior of the recents screen (unlikely but worth a check)
For this, I suggest using a stock launcher or try the same app on a different phone or an emulator.
What would help is steps you followed and some screen shots of recents
screen and also of your app
I had the same problem.
The reason is that I had set android:label="" in manifest.xml.
I hadn't set android:launchMode="singleTop".
I declared on purpose android:label="" because I didn't find any better way to remove the title of the action bar from my main activity.
I turned android:label="app_name" again and everything now is OK; the app appears again in recent app list when pressing the home screen and doesn't start on the last navigated screen when restarting it.
So I've managed to get the settings button to appear while in the preview for my live wallpaper. The only issue I'm having is that it's not shooting me to my preference activity. (I've logged it and I never enter the activity).
I have a feeling I must have made a mistake in the XML somewhere... But I cant seem to spot it.
Here's my wallpaper.xml
<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="#drawable/icon"
android:description="#string/wallpaper_description"
android:settingsActivity="com.company.app.package.LiveWallpaperPrefs">
</wallpaper>
Here's the relevant snippet from my manifest.
<service
android:name="com.company.app.package.LiveWallpaperService"
android:enabled="true"
android:icon="#drawable/icon"
android:label="app"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter android:priority="1" >
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/wallpaper" />
</service>
<activity android:name="com.company.app.package.LiveWallpaperPrefs"/>
Anybody know why It's not sending me to my LiveWallpaperPrefs when I press settings? It's actually currently giving me an error "Unfortunately, Live Wallpaper Picker has stopped."
Thanks!
Actually figured it out... I wasn't giving the system permission to enter that settings portion of my app from outside of my app... Here's what fixed my code.
In the manifest (replacing the old LiveWallpaperPrefs)
<activity android:name="com.company.app.package.LiveWallpaperPrefs">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
You could export the LiveWallpaperPrefs like this:
<activity
android:name="com.company.app.package.LiveWallpaperPrefs"
android:exported="true" />
I realize this question is a bit old, but I was having a similar problem. None of the suggestions I found online seemed to be working. No matter what I did, the settings would not display when you tapped the button.
After wasting about 3 hours, I realized that it WAS working, but for some reason I had to completely REMOVE the app from the device and re-install it fresh.
Usually, cleaning the project and re-uploading it to the device actually changes the app. But for some reason the change would not take effect until the app was removed and re-installed.
Hope this helps someone in the future!
I'm having a problem with my app after changing the default activity in the manifest. This is the manifest after i changed it. As far as i can see it's syntactically correct.
<application android:icon="#drawable/icon" android:label="#string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".loginActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="CouncilPlannerActivity"></activity>
<activity android:name="MainTabActivity"></activity>
<activity android:name="MapTabActivity" android:theme="#android:style/Theme.NoTitleBar"></activity>
<activity android:name="NodeFormActivity"></activity>
<activity android:name="viewNewsActivity"></activity>
</application>
The problem is when i deploy the app to my device it works fine first time. However, when i close the app with the home button it refuses to open again. Clicking the icon in the devices app list doesn't do anything.
If i change the default activity to the one it was at originally it works fine. Is this a bug or is there another reference to a default activity that i'm missing?
I'm developing on Android 2.2 if that makes a difference.
I just noticed the logcat spits out an error when i try to open the app : "Permission Denied: checkComponentPermission() reqUID10064"
You probably need to post the loginActivity in question here so we can see if there are any problems in the activity. Otherwise double check that the loginActivity is in the same package as the other activities, if its not you need to change the ".loginActivity" part of the manifest to its relative location to the main package, aka "somename.loginActivity"
I think the problem is in loginActivity class. May be you check for already loggined user and finish activity in this case?