I have a project with two apps written in React Native. Since I do not currently support a dark theme, users with dark-mode enabled on their devices get bad colors in my app. Therefore I want to disable the dark-mode in my app, until the time I have support for it.
In my first application, I have successfully disabled dark mode. But in my second app, I did the exact same thing, but still dark mode affects my colors. This is how my styles.xml looks like, and I also do not have any styles-night.xml or anything like that.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColor">#000000</item>
<item name="android:forceDarkAllowed">false</item>
</style>
<style name="AppTheme.Launcher">
<item name="android:windowBackground">#drawable/launch</item>
<item name="android:forceDarkAllowed">false</item>
</style>
</resources>
This is my AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.myappname">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:forceDarkAllowed="false"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="secretkey"/>
<activity
android:name=".MainActivity"
android:exported="true"
android:label="#string/app_name"
android:theme="#style/AppTheme.Launcher"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:forceDarkAllowed="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
tools:targetApi="q">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have cleaned the build, and rebuilt it again, but still to no effect. Am I missing something? I know there is an option to disable the dark mode in the onCreate function, but that will just recreate the activity and thus slow down the app startup, which I do not want.
It's complicade because you can try many things but if you buy a theme of other developer maybe the code have lines to force the dark mode. I bought a theme a have this lines, like this:
export const useTheme = () => {
const isDarkMode = useColorScheme() === 'dark';
const forceDark = useSelector(state => state.application.force_dark);
const themeStorage = useSelector(state => state.application.theme);
const listTheme = ThemeSupport.filter(item => item.theme == themeStorage);
const theme = listTheme.length > 0 ? listTheme[0] : DefaultTheme;
if (forceDark) {
return {theme: theme.dark, colors: theme.dark.colors}; <--- change here
}
if (forceDark === false) {
return {theme: theme.light, colors: theme.light.colors};
}
return isDarkMode
? {theme: theme.dark, colors: theme.dark.colors} <----- change here
: {theme: theme.light, colors: theme.light.colors};
};
So I change dark to ligth and solved my problem.
Related
I access to my internal storage and camera in release mode with intellij idea. But when I generate the apk and deploy in a real android device it does not work.
Can you help me please?
This is my android manifest. When I want to access to the camera or the storage or googlemaplocation. It does nothing.
Thanks
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lesvoisins.app.simo.rafik.lesvoisins_flutterV2">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="lesvoisins_flutterV2"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
</application>
this problem is confusing me and i can't see where the issue is. when i change my app name and icon my launch activity name and icon (the one that shows at the top left screen) changes to that name and icon. But when i check the xml file of the launch activity it shows me otherwise.
App name : online shop
Activity name : Anmeldung
here is the Graphical layout in eclipse of the activity and that's how it supose to be :
and here is the activity in the emulator :
Androidmanifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dbreader"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_login"
android:label="#string/activity_login"
android:theme="#style/AppTheme" >
<activity
android:name="com.hochschule.main.Login"
android:icon="#drawable/ic_launcher"
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="com.hochschule.main.Registrieren"
android:icon="#drawable/ic_registrieren"
android:label="#string/title_activity_registrieren" >
</activity>
<activity
android:name="com.hochschule.main.Shop"
android:icon="#drawable/ic_launcher"
android:label="#string/title_activity_shop" >
</activity>
<activity
android:name="com.hochschule.main.WarenKorb"
android:icon="#drawable/ic_warenkorb"
android:label="#string/title_activity_waren_korb" >
</activity>
</application>
</manifest>
Android label tag is used for both Default Title bar and App Name in Home Screen
android:label="#string/app_name"
It may conflict with activity's label name sometimes. You can apply the programmatic method as alternative which surely works.
If you want to set Activity to your desired name in onCreate() in your activity as below:
this.setTitle("Your Title");
To set Icon:
getActionBar().setIcon(R.drawable.Your_Icon);
If you are using the support library to add the actionbar (ex: ToolBar), use getSupportActionBar instead of getActionBar.
Hope this helps.
In my app, I am integrating progress dialogue and I am using below code for creating progress dialogue
public static void showProgressDialogue(final Context context, String title, String mainMessage) {
progressDialog = new ProgressDialog(context);
progressDialog.setTitle(title);
progressDialog.setMessage(mainMessage);
progressDialog.setIndeterminate(false);
progressDialog.show();
}
And I created 2 emulators one for lollipop and other for marsh mallow. It is showing title and message on lollipop emulator but not showing title and message on marsh mallow emulator. Further I have tried on real device as well. On marsh mallow (Motorolla droid turbo) device it is not showing title and message. For sake of giving complete understanding i am attaching images as well
Above images is taken of lollipop emulator
Above image is taken from marsh mallow emulator
I have googled a lot and could not fine suitable answer that solve my query. Even in one place I found that by changing 'textColorPrimary', it will work. But in my case it did not work. And below is my style.xml code
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/black</item>
<item name="android:textViewStyle">#style/LoyaltyTextView</item>
<item name="editTextStyle">#style/LoyaltyEditText</item>
</style>
Any help?
As requested, I am posting my manifest as well
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".views.activities.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
</activity>
<activity android:name=".views.activities.MainActivity"/>
<activity android:name=".views.activities.LoginActivity"/>
<activity android:name=".views.activities.SignUpActivity"/>
<activity android:name=".views.activities.ViewAsGuest"/>
<activity android:name=".views.activities.BusinessActivity"/>
</application>
I've created a :core module that stores some of my basic activities, some of these should show an actionbar, in the manifest I've something like this:
<activity
android:name=".components.home.HomeActivity"
android:theme="#android:style/Theme.Holo.NoActionBar">
</activity>
<activity
android:name=".components.activities.ContactsActivity"
android:theme="#style/AppTheme.TranslucentActionBar" >
</activity>
I don't understand why but now that I've created another module :extension that includes :core, the actionbars in that activities seems to not show.
The manifest of extension is very simple:
<application
android:name=".App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:icon" >
<activity
android:name=".components.activities.TestActivity"
android:label="#string/title_activity_test" >
</activity>
<activity
android:name=".components.home.WelcomeActivity"
android:label="#string/title_activity_welcome"
android:theme="#style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Usually this is a problem that concerns themes, but to me everything seems fine, I don't understand why it works when I build simply :core, but it doesn't work when building :extension project
I've spent too much time when the answer was easy.
Pressing Ctrl+click made me see how the theme was made, I've simply switched parent to the old layout.
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
In my Android Application I have a Google MapView Activity and I am facing the following Error:
MapView: Couldn't get connection factory client
At first: I have a right Maps Key and the Internetpermission and the Map is displaying fine on Emulator and Device. The thing that I am confused about is that although the map works, the above error displays.
On the Device sometimes the Map loads and displays correctly and 1 minute later, if start to zoom and pinch the map the map does not continue loading and throws the error.
If I switch off and on again the mobile network on the device the map works fine again.
Edit: my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="de.incowia.mobileschatzsuche"
android:versionCode="1"
android:versionName="2011.10.07">
<!-- We're supporting AndroidSDK 7 -->
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7"/>
<!-- We need access to the internet for loading maps -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- We're using both, network and GPS -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:theme="#style/DefaultTheme">
<!-- 4 test -->
<uses-library android:name="android.test.runner" />
<!-- We're using Google Maps API -->
<uses-library android:required="true" android:name="com.google.android.maps" />
<!-- Dashboard -->
<activity android:name=".MobileSchatzsucheActivity" android:label="#string/app_name" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Maps Activity -->
<activity android:name=".GoogleMapsActivity" />
<!-- Schatzliste Activity -->
<activity android:name=".SchatzlisteActivity" android:launchMode="singleTask"/>
<!-- Schatzdetails Activity -->
<activity android:name=".DetailsActivity"/>
<!-- MyTreasuresCoverFlowActivity -->
<activity android:name=".MyTreasuresCoverFlowActivity"/>
<!-- Preferences Activity-->
<activity android:name=".PreferencesActivity"
android:theme="#android:style/Theme"/>
<!-- FileBrowser Activity -->
<activity android:name=".FileBrowserActivity"
android:theme="#android:style/Theme"/>
</application>
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="de.incowia.mobileschatzsuche"
android:label="test test" />
</manifest>
Just try to give these Two Permission
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
Because when you zoom in/zoom out the Google map goes accordingly in/out, so for that we need to give such permission.
It will work then