why this screen, while app opens every time - android

Here I am getting this screen every time just like a splash for few seconds and then opening the home activity.I don't want to this screen in my app. How to fix it.
Here is my manifest file
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.asdf.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>
For your Information, I am using Support Library for developing.
I changed the app Style to "#android:style/Theme.Translucent.NoTitleBar" then this screen is not showing but It has the impact on other UI components of the same App like.. Spinner, text-view etc.

Add this line in your style.xml
<style name="AppTheme" parent="android:style/Theme.Holo">
<item name="android:windowDisablePreview">true</item>
try this..well previous one should work.It worked for me

If you want to remove the title bar, then use the following in your Activity initialization:
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
...

move Intent-filter code to whichever activity of your application. and remove that activity code.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Hope it will work

Related

Android app showing 2 icon in device while testing

I'm new to android and Developing very basic App. I have completed my development but when ever I debug my app in device. It shows 2 icon. I'm facing this problem after implementing Splash Screen in my app. Please suggest me how to overcome. My manifest
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/icc"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SplashScreen"
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=".Login_page">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In your manifest file -
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
This piece of code means which activity will first start when you launch the app. But you have put this code in both of your activities hence Android provides a separate launcher for both the activities and you see two icons.
So remove the above code from one of the activities. Just let it remain in the Activity you want to start first when your app launches.
TO have a icon on the launcher screen you need action of the activity to be action_main and category to be launcher and your both activity qualifies the criteria for this.
You should change your login_activity category to default or simply remove the category.
You can start your login activity from splash activity.
I hope it helps you.

AppCompat Theme Error when using NoActionBar

I'm using a toolbar for my entire application. So I have set up my application Theme to Theme.AppCompat.Light.NoActionBar But I need to show a alert dialog in a part of my app. When I try to show alert dialog I'm getting Runtime error about Theme.Appcompat
My manifest.xml file
<application
android:allowBackup="true"
android:icon="#drawable/app_icon2"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
>
<activity
android:name="com.project.project.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="com.project.project.StActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="#string/app_name">
<intent-filter >
<action android:name="android.intent.action.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
What should i do
Thanks for help
It's hard to tell without seeing the code where you actually create the Dialog, but my guess is that you're either:
Not using the Activity as the Context when you create the Dialog. The Activity context holds the theme; if you tried using the Application it wouldn't get the right theme.
Setting your Dialog theme to something that doesn't inherit from Theme.AppCompat (using the constructor, setStyle() or ContextThemeWrapper).
Either way, the Dialog doesn't get the required attributes provided by Theme.AppCompat.

Why can't I change the label in the action bar for each screen in my app?

The action bar for the 2 activities I have don't have a label. I want the main screen to have the app name and the next screen to have a different label. Here is my manifest file:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:theme="#style/MSTheme" >
<activity
android:name="com.android.recipme.MainScreen"
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.android.recipme.MyRecipes"
android:label="#string/my_recipes" >
</activity>
</application>
I've searched for some answers and can't seem to get anything right. Please help thanks!
To change the title of the desired activity, including the following line should be what you want, usually onCreate( ) is where you'd want to put this:
setTitle("SetYourTitle Here");
You can refer to this thread for more information: How to change the text on the action bar

Every Activity of my application is shown as an app on its own

Just like the title says, for some reason which I dont understand, Every Activity I create in my application is shown as an icon for an application on the phone's app menu.
Could someone please help me solve this wierd problem?
If you need some code just ask for it (I dont know which code is related with these kind of stuff).
Thanks!
In your manifest remove these lines from all Activities except the one you want to open on:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Example:
<activity
android:name="your.package.name.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<!-- This line declares this Activity as the start point -->
<action android:name="android.intent.action.MAIN" />
<!-- This line adds a launcher icon -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="your.package.name.OtherActivity"
android:label="#string/app_name" >
</activity>
In your manifest file you must have set launcher intent-filter for all of your activities.. Keep launcher intent-filter only in launcher activity..

Can I set the name of the app to something other than the label of the activity with the intent-filter?

I have an app with four activities. I have set the intent-filter on one of them so it will be displayed first to the user when he starts the app. It has a label that says "Add expense".
Now the name under the icon for the app in the phone says "Add expense".
I would like the activities to have their different labels because they are displayed in the menu at the top of each activity and help the user understand what the activity is about. But I want the app name to be something other than the label of the activity with the intent-filter.
Is that possible?
Part of my manifest:
As you can see I've tried to set android:label="#string/app_name" on the application level but that doesn't work. The label on the activity is displayed under the icon anyway.
<application
android:icon="#drawable/ic_money_bag"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light" >
<activity
android:name=".AddExpenseActivity"
android:label="#string/add_expense_header" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListExpensesActivity"
android:label="#string/list_expenses_header" >
</activity>
<activity
android:name=".AddExpenseAccountActivity"
android:label="#string/add_expense_account_header" />
<activity
android:name=".ListExpenseAccountsActivity"
android:label="#string/list_expense_accounts_header" />
</application>
Regards,
Mattias
You can use setTitle(String s) in each activity to change the name that appears in the title bar dynamically. So for you setting it in onCreate to whatever you want might suffice.
setTitle("Hello StackOverflow");
Try giving
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
When the label is specified for the activity then i will be shown with the same label in Launcher
What can u do is give label to intent-filter

Categories

Resources