How to open application to run code without showing activity - java

I want when the user click on my application (when he open my application) the application run java without open the application or showing any activity.
Like Fast Task killer application.
And thanks.

Create transparent activity for this
Here’s a complete file:
res/values/styles.xml
<resources>
<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>
</resources>
Then apply the style to your activity, for example:
<activity android:name=".SampleActivity" android:theme="#style/Theme.Transparent">
...
</activity>

Related

Android Navigation Fragment background is black without setting

First in my Android Stuidio, it look like this :
enter image description here
But in my Android Phone, it look like this:
enter image description here
When I turn to task List, it look like this:
enter image description here
Here are the themes.xml code:
themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.ShareChargingPile2.Fullscreen" parent="Theme.ShareChargingPile2">
<item name="android:actionBarStyle">
#style/Widget.Theme.ShareChargingPile2.ActionBar.Fullscreen
</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
</style>
<style name="ThemeOverlay.ShareChargingPile2.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">#color/light_blue_600</item>
<item name="fullscreenTextColor">#color/light_blue_A200</item>
</style>
</resources>
Question: Why the background of my application is black? And how to fix this?
Solved
In the themes.xml
<style name="Theme.ShareChargingPile2.Fullscreen" parent="Theme.ShareChargingPile2">
<item name="android:actionBarStyle">
#style/Widget.Theme.ShareChargingPile2.ActionBar.Fullscreen
</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
</style>
the windowBackground is #null.
I change to #color/white. The problem solved
<style name="Theme.ShareChargingPile2.Fullscreen" parent="Theme.ShareChargingPile2">
<item name="android:actionBarStyle">
#style/Widget.Theme.ShareChargingPile2.ActionBar.Fullscreen
</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#color/white</item>
</style>
your phone dark mode is on or you can change in res->values->themes->themes.xml(night)change black to white or something else color.

how to set app open ad backgroung color in android?

My code is here!
appOpenAd.show(currentActivity);appOpenAd.setFullScreenContentCallback(fullScreenContentCallback); currentActivity.getWindow().getDecorView().setBackgroundColor(Color.BLACK); appOpenAd.show(currentActivity);
The link below in which app open ad have black color when ad is showing.
https://play.google.com/store/apps/details?id=com.freescanner.qrcodereader.barcodescanner.barcodereader.socialmobileapps
first create a file theme.xml and copy the code given below.
<resources>
<style name="myAdTheme" parent="Theme.AppCompat.DayNight.NoActionBar" >
<item name="android:background">#000000</item>
<item name="android:windowBackground">#000000</item>
<item name="android:windowExitAnimation">#null</item>
<item name="android:windowEnterAnimation">#null</item>
</style>
</resources>
after this just ad these lines to your AndroidManifest.xml file
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:theme="#style/AdTheme"
tools:replace="android:theme"
/>

Why I see Do not request Window.FEATURE_SUPPORT_ACTION_BAR?

This is a simple app with a tag navigation. And I can't open it with getting a mistake.
A part of it is:
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at androidx.appcompat.app.AppCompatDelegateImpl.setSupportActionBar(AppCompatDelegateImpl.java:572)
at androidx.appcompat.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:159)
at com.example.tabexperiment.MainActivity.onCreate(MainActivity.java:29)
And here is a 28-th and 29-th lines in MainActivity(the message above says mistake is in 29-th line):
androidx.appcompat.widget.Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
I tried to cope with the problem but all what I found is that I should add this code in themes file:
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
and this line in Manifest:
android:theme="#style/Theme.TabExperiment"
So, I have that in my code but nothing is still working.
Help me, please.
you can use this:
<style name="NoActionBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
OR
<activity android:name=".activity.YourActivity"
android:theme="#style/AppTheme.NoActionBar"/>

Unable to generate apk file in Android Studio due to ResourceCycle error

I am trying to generate the signed apk file for my app in android studio. I was able to do this successfully before but after changing one line of code, I get an error. The line of code I changed was in strings.xml.
from
<resources>
<string name="app_name">Flashlight</string>
<string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
</resources>
to
<resources>
<string name="app_name">Flashlight</string>
<string name="banner_ad_unit_id">ca-app-pub-6203674096217868/4182598236</string>
</resources>
All I did was change the admob test ad id to my real ad id. Now I get this error:
Error:Error: Style Resource definition cycle: TextAppearance.AppCompat.Light.SearchResult.Title => TextAppearance.AppCompat.SearchResult.Title => TextAppearance.AppCompat.SearchResult.Title [ResourceCycle]
Explanation for issues of type "ResourceCycle":
There should be no cycles in resource definitions as this can lead to
runtime exceptions.
Here is my styles.xml file:
<resources>
<!-- Base application theme. -->
<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>
</style>
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
</resources>
I appreciate any help as I have tried googling the error but to no avail.
I found a solution to my problem. The issue resided within my app file and I changed
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.android.support:support-v4:24.0.0-alpha1'
to
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'

Custom Background Color for ActionBar settings area

I would like to change the color of my settings Tab located on the ActionBar, I have done very extensive research here and in other sources.
My Android version is 4.4.2.
My manifest is declared this way:
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="19" />
Basically I am doing what other sources showed me to:
<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:panelFullBackground">#drawable/menu_background</item>
</style>
I also have replaced the android:panelFullBackground property for android:panelBackground, android:panelColorBackground and android:panelColorForeground switching from drawable resources to color values for each without results.
Finally I have also tried using ListPopupWindow parent variant:
<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:panelFullBackground">#drawable/menu_background</item>
</style>
Here I have also switched the android:panelFullBackground property for android:panelColorBackground and android:popupBackground properties mixing them up with #android:color and #drawable resources too but is not working either.
Can you please tell me an effective way to configure this through the styles.xml file?
Thank you very much
Maybe you need to use Android Asset studio's ActionBarStyleGenerator to easily handle colors and not going through all the stuff. If you need more customizing on each Tab then you need to get a reference to actionbar using getActionBar()(or getSupportActionBar() in case of support actionbar) and create custom views Programmatically and add them to your actionbar using addTab(...)
I managed to find the right setting for my styles to accomplish the action bar settings custom color. This post helped as well: How to change the background color of Action Bar's Option Menu in Android 4.2?
The styles go this way:
File styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
</style>
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:itemTextAppearance">#style/TextAppearance</item>
</style>
<style name="MyActionBarTheme" parent="#android:Widget.Holo.Light.ActionBar">
<item name="android:background">#3892D3</item>
<item name="android:titleTextStyle">#style/MyActionBarTheme.Text</item>
</style>
<!--
This style reference did it, you can put a drawable resource or color resource reference there as well. For example: #drawable/menu_dropdown_image or #android:color/white
-->
<style name="PopupMenu" parent="#android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#3892D3</item>
</style>
<!---->
<style name="MyActionBarTheme.Text" parent="#android:TextAppearance">
<item name="android:textColor">#android:color/white</item>
<item name="android:textSize">20sp</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">#android:color/white</item>
</style>
</resources>
Thank you!

Categories

Resources