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>
Related
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.
I have an activity that open from browser when Device is in Landscape get me below error
java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
Manifest
<activity android:name=".Activity.MyActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.Theme_Slide"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="xxx"
android:scheme="xxx" />
<data
android:host="xxx"
android:scheme="xxx" />
</intent-filter>
</activity>
style.xml
<style name="AppTheme.Theme_Slide" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
UPDATE FIND SOLUTION
In android Oreo (API 26) you can not change orientation for Activity that have below line in style
<item name="android:windowIsTranslucent">true</item>
You have two way for solving this :
You can simply remove above line (or turn it to false) and your app works fine.
Or you can first remove below line from manifest for that activity
android:screenOrientation="portrait"
Then you must add this line to java file
//android O fix bug orientation
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Has anyone used 1GravityContactsPicker Library for android.
I just found this yesterday and decided to use this in my app due to its good features. I did everything as mentioned in the steps but when i am starting the activity I am getting a Toast message saying
Attribute undefined; "cp_textColorPrimary". Did you apply the correct
theme
i have checked the documentation of library and heres what i did
1) Added dependency to gradle
2) Added activity file to manifest
3) Enabled contacts permission
4) below is the code
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ContactPickerActivity.class)
.putExtra(ContactPickerActivity.EXTRA_THEME, R.style.ContactPicker_Theme_Dark)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_BADGE_TYPE,
ContactPictureType.ROUND.name())
.putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION,
ContactDescription.ADDRESS.name())
.putExtra(ContactPickerActivity.EXTRA_SHOW_CHECK_ALL, true)
.putExtra(ContactPickerActivity.EXTRA_SELECT_CONTACTS_LIMIT, 0)
.putExtra(ContactPickerActivity.EXTRA_ONLY_CONTACTS_WITH_PHONE, false)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION_TYPE,
ContactsContract.CommonDataKinds.Email.TYPE_WORK)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_SORT_ORDER,
ContactSortOrder.AUTOMATIC.name());
startActivityForResult(intent, REQUEST_CONTACT);
}
});
can anyone please help me out with this
I have the same issue.
it's because in his Actvity he test the AppThem directly and if your Application themes does not implement Picker style the check is all time false.
// check if all custom attributes are defined
if (! checkTheming()) {
finish();
return;
}
For fix it, i've juste add new themes in styles.xml
<!-- LIGHT Theme -->
<style name="Theme_Light_Base" parent="#style/ContactPicker_Theme_Light">
<!-- ActionBarCompat -->
<item name="colorPrimary">#color/colorPrimary_light</item>
<item name="colorAccent">#color/colorAccent_light</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark_light</item>
<item name="backgroundColor">#color/background_light</item>
<!--<item name="icTheme">#drawable/ic_palette_black_36dp</item>-->
<!--<item name="icPickContact">#drawable/ic_person_add_black_36dp</item>-->
</style>
<style name="Theme_Light_picker" parent="#style/Theme_Light_Base"/>
<!-- DARK Theme -->
<style name="Theme_Dark_Base" parent="#style/ContactPicker_Theme_Dark">
<!-- ActionBarCompat -->
<item name="colorPrimary">#color/colorPrimary_dark</item>
<item name="colorAccent">#color/colorAccent_dark</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark_dark</item>
<item name="backgroundColor">#color/background_dark</item>
<!--<item name="icTheme">#drawable/ic_palette_white_36dp</item>-->
<!--<item name="icPickContact">#drawable/ic_person_add_white_36dp</item>-->
</style>
and after apply directly on the ActivityPicker in AndroidManifest.xml :
<activity
android:name="com.onegravity.contactpicker.core.ContactPickerActivity"
android:enabled="true"
android:exported="false"
android:theme="#style/Theme_Light_picker">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
I have create demo application in Android Studio with two Activity. In First Activity Show Title Bar in preview as well as in emulator but on second Activity does not show Title Bar in Emulator but it display in preview. I have used API 22 in Android Studio.
Please help me....thanx in advn
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/BaseTheme">
<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=".DrawingActivity"
android:label="#string/app_name"
android:theme="#style/BaseTheme"
android:screenOrientation="portrait" />
</application>
Theme style file like this....
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="BaseTheme" parent="AppTheme">
<item name="colorPrimary">#color/action_bar_backgound</item>
</style>
I have also try this...
First Activity Work's fine so I have set that in Second Activity as a setContentView(R.layout.activity_main);
MainActivity.java
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buttonAction(View v) {
Intent intent = new Intent(MainActivity.this, DrawingActivity.class);
startActivity(intent);
}
}
DrawActivity.java
public class DrawingActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
What you are facing is a bug related to the API 22(5.1) SDK.
Kindly refer the following links for the details on the bug in which the Action Bar is not displayed:
https://code.google.com/p/android/issues/detail?id=159793
https://code.google.com/p/android/issues/detail?id=159780
What you can do for now
Either revert back to API 21 if possible or,
Select API 21 in the compile with (render with) option in Android Studio.
Hope this helps.
There are a lot of similar questions on StackOverfow but they don't solve my problem.
The task is to process in Service intents sent with default share mechanism (ACTION_SEND) from different applications.
But as far as ACTION_SEND is an activity action we have to pick up intent in activity and broadcast it to service. And it will be perfect if this activity will be invisible to the user.
I've researched a lot and have tried many solutions already.
First step of making activity invisible belongs to activity style.
I've tried this values.
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:theme="#android:style/Theme.Translucent"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
Also i"ve tried to create a custom theme.
<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:backgroundDimEnabled">true</item>
</style>
How the activity in AndroidManifest.xml looks like.
<activity
android:name="xxx.xxx.activities.HandleShareIntentActivity"
android:theme="#style/Theme.Transparent"
android:noHistory="true"
android:excludeFromRecents="true"
android:label="#string/title_activity_handle_share_intent">
<intent-filter>
<action android:name="com.google.android.gm.action.AUTO_SEND"/>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="com.google.android.voicesearch.SELF_NOTE"/>
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
Activity code. No setContentView(). finish() in onCreate().
public class HandleShareIntentActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startService(new Intent(this, xxxService.class).putExtra(
Constants.ACTION_SHARE_KEY, getIntent()));
finish();
}
}
On Nexus 5, android 4.4.4 I do have black screen blink while handling any share event.
Any solutions?
I've tried this values.
Use Theme.NoDisplay.
I Just did this, and it helped in my case:
<activity
android:name=".SensorBoardActivity"
android:theme="#android:style/Theme.NoDisplay"
android:excludeFromRecents="true"
android:noHistory="true">
I see you already have finish(); but just for others it is important to execute it just before leaving the onCreate().