After creating my main activity now I am adding splash screen but the splash intent is not opening the main activity.
After editing the manifest file
define .mainActivity outside .splash activity in manifest file
like below
cut
<activity android:name=".MainActivity"></activity>
and paste above
<activity android:name=".CustomList"></activity>
just change your manifest file like this
declare your MAinActivity outside the splash activity tag like this
<application>
<activity android:name=".splash" />
<activity android:name=".MainActivity" />
<activity android:name=".customlist" />
</application>
Related
have done a project with buttons to allow me to navigate on the web but I'm getting an error and my app is stopping right after the splashscreen. any help??
In your Manifest add following <activity /> tag after your MainActivity's <activity> block:
<activity
android:name=".LMCome"
android:parentActivityName=".MainActivity" />
I need to disable splash screen auto rotate.
Need to show splash screen in portrait mode only. But app must rotate with auto rotate. How to do it in android studio ?
Add in Manifest file-->
<application
.........
>
<activity
android:name=".SplashScreenActivity"
......
android:screenOrientation="portrait"
/>
</application>
or for horizontal mode
<activity
...
...
android:screenOrientation="landscape">
In Your AndroidMainfest.xml put the screen orientation to your splash
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In the manifest, set this for your splash screen activity:
<activity android:name=".YourActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"/>
In manifest you can set the specific activity to be in portrait mode using
android:screenOrientation="portrait"
Just add below line in your manifest file, in splash activity tag
android:screenOrientation="portrait"
Something like below
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait" >
Add to your splash activity declaration in the manifest this lines:
<activity
android:name="SplashActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
Find relevant discussion here.
You Can do it by couple of ways
One
Inside the onCreate method of your activity
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Two
In manifest file
<activity
android:name=".NameOfYourSplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hope it helps
Add following code to your splash screen activity declaration in Manifest
<activity android:name=".YourActivityName"
android:label="#string/app_name"
android:configChanges = "orientation"
android:screenOrientation = "portrait">
or else add
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
to YourActivity.onCreate()
you can find a sample demo file here in github
try this in manifiest
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"/>
I am very new to android development with eclipse, and I encounter dozen of errors and problems. Here is the next one:
I am following an android tutorial given here in order to set up the action bar. In this tutorial is says to insert an activity as follows:
<activity android:theme="#style/Theme.AppCompat.Light" ... >
Can I just put this line into the xml manifest file?
<activity android:theme="#style/Theme.AppCompat.Light">
Or do I need to replace the '...' by something more useful?
Please read the docs: activity-element
The activity's name is required, so you would need to have:
<activity android:theme="#style/Theme.AppCompat.Light" android:name="MyActivity">
Other than that, you are not required to add any other attributes.
Although be sure to place the activity element within the proper place in your xml. It should be contained in your application block:
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light">
<activity android:name="MyActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Unless you really want your app to work under API levels under 3.0 then you have to add it like this.
android:theme="#style/Theme.AppCompat.Light"
Inside your already defined activity in your manifest (the one that has the intent filter and other declarations).
otherwise you dont have to add that at all.
This is one example.
<activity
android:name=".MainActivity"
android:theme="#style/Theme.AppCompat.Light"
android:screenOrientation="portrait"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and this is another
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme=#style/Theme.AppCompat.Light"" >
<activity android:name=".DetailActivity"
android:label="#string/app_name" >
</activity>
The second way you posted is just fine, be sure to close the activity tag so it looks like <activity android:theme="#style/Theme.AppCompat.Light"></activity>
Also, if you're using eclipse, it is easier to go into the AndroidManifest and under the Application tab scroll to the bottom where there's Application Nodes and then add your view from there. Eclipse will auto generate the correct code in the xml file.
In my project I create several class and I am able to going from one activity to other , but the problem is when I press back menu all activity reversed I don't want that!!! below is manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bones.samples.android"
android:versionCode="1"
android:versionName="1.0">
<application android:label="#string/app_name" android:icon="#drawable/icon48x48" android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<activity android:label="#string/app_name" android:screenOrientation="landscape" android:name=".stage">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="LevelOne" android:screenOrientation="landscape" ></activity>
<activity android:name="dialogue" android:theme="#android:style/Theme.Dialog" ></activity>
<activity android:name="FailDialogue" android:theme="#android:style/Theme.Dialog" ></activity>
<activity android:name="LevelTwo" android:screenOrientation="landscape" ></activity>
<activity android:name="LevelThree" android:screenOrientation="landscape" ></activity>
</application>
<uses-sdk android:minSdkVersion="10" />
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens= "true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE"/>
</manifest>
I want that when I am on leveltwo or dilogeue activity and press back button it directly go to stage activity but not in reverse all activities.
If you call one activity after another without calling finish, the activities are preserved in the back stack for further access.
If you dont want the activities to show up when the user presses back, keep calling finish method after calling the activity you want.
For Ex:-
Intent intent =new Intenet(this, NextActivity.class);
startActivity(intent);
finish();
This will close the current activity and will start the next activity. Now, when the user presses back, it will go the the activity earlier than this activity else, your application will close.
If you want to go to a specific activity, you can override the onBackPressed method and call a specific activity too.
Use:
YourActivity.this.finish()
after calling the intent to next activity, for all activities you dont want to display on BackPress.
if the above is not feasible, you can define the parent activity for up navigation:
Beginning in Android 4.1 (API level 16), you can declare the logical parent of each activity by specifying the android:parentActivityName attribute in the element.
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
This is what the Docs say
startActivity(CurrentActivity.this,NextActivity.class);
finish();
or
set flag on your manifest file
read below thread for more info
http://developer.android.com/guide/components/tasks-and-back-stack.html
or
Use fragment. u can replace the fragment . finally u can finish the activity.
Use this into Manifest...
android:noHistory="true"
as below...
<activity android:name="LevelOne" android:screenOrientation="landscape"
android:noHistory="true" ></activity>
<activity android:name="dialogue" android:theme="#android:style/Theme.Dialog"
android:noHistory="true" ></activity>
<activity android:name="FailDialogue" android:theme="#android:style/Theme.Dialog"
android:noHistory="true" ></activity>
This attribute will remove the current Activity from the Activity Stack when another Activity will start from this Activity...So, when you will press back button then it will not return to that previous Activity.
what is the meaning of line
" and add the corresponding activity tags to the Android Manifest
file"
in the tab example on
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
under step 2.
i added the activity tags and it's still dont work
<activity android:name=".ArtistsActivity" android:label="#string/app_name" />
<activity android:name=".AlbumsActivity" android:label="#string/app_name" />
<activity android:name=".SongsActivity" android:label="#string/app_name" />
Every time you create a new activity in android, you have to add an activity tag to your android manifest file. Take a peek at this example,
http://developer.android.com/guide/topics/manifest/activity-element.html
It means add your activities to your manifest.
<activity android:name=".HelloTabWidget">