How to change Activity Priority in Android Studio - java

Iam trying to add Splash screen to my existing Android Project, which is not MainActivity.Java, but by default Android Studio is executing MainActivity.Java first, So I want to change the Activity Priority so that my SplashActivity.Java will execute first and later Activity's will follow after the Splash Screen.

Make splash activity your launcher activity instead of Main Activity in Android Manifest.
<activity
android:name=".ui.splash.SplashActivity"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

modify your AndroidManifest.xml like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.circlefil.reactivetrip">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"/>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

You need to add IntentFilter in you splash screen activity and from splash screen activity you have to link your main activity using Intent.
Add following code to your splash screen activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
How ever keeping an entire activity is not the best way to create splash screen. See this for more info: Here

To Start activity first you need to make it Launcher Activity in AndroidManifest.xml file.
<activity
android:name=".StartingActivityName">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Related

no resource identifier found for attribute 'launchmode' in package android

This is my AndroidManifiest.xml File
Their is 2 error
no resource identifier found for attribute 'launchmode' in package android
no resource identifier found for attribute 'stateNotNeeded' in package android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="a52.puri.fbkunal.com.launcher">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:stateNotNeeded="true"
android:
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
</application>
</manifest>
You are assigning unknown property for application tag, launchMode in android is for Activities. Activities launch and visible to user but Application launch only once when you start your App. You can say Application is a start point in Android App.
Assign a launchMode into Activity not in application tag.
Basically we could assign a launchMode directly as an attribute of <activity> tag inside AndroidManifest.xml file list this:
<activity
android:name=".SingleTaskActivity"
android:label="singleTask launchMode"
android:launchMode="singleTask">

Convert Android Widget to an App with a Widget

I have an Android widget (it is shown in the list of widgets on the phone, and is not shown in the list of apps). It has a button which launches a pop-up activity.
Now I would like to change the widget so, that it would be both an app (which will be shown in the list of apps on the phone) which will start from that pop-up activity, and a widget (the same as before) which will launch the app (which will consist of that pop-up activity, but will be displayed and treated like an app).
What changes should I make in my manifest file to make the changes described above?
Below is my manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar" >
<receiver android:name="myapp.myapp.MyWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/demo_widget_provider" />
</receiver>
<receiver
android:name="myapp.myapp.MyWidgetIntentReceiver"
android:label="widgetBroadcastReceiver" >
<intent-filter>
<action android:name="GET_HELP" />
<action android:name="CHANGE_PICTURE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/demo_widget_provider" />
</receiver>
<activity
android:name="myapp.myapp.MainActivity"
android:label="#string/title_activity_main" >
</activity>
<activity
android:name="myapp.myapp.CardsChoice"
android:label="#string/title_activity_choice" >
</activity>
</application>
The solution was rather simple: I just needed to add a Launcher Activity to the app.
This operation consists of 2 steps:
Adding activity definition as a launcher activity to the Manifest
Example:
<activity
android:name="package.package"
android:label="#string/title_activity_main"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Adding code of the activity (and the layout) to the app.
It is about an class MainActivity and a layout file activity_main.xml

What is the best way to switch Android Activities?

I have been developing a map app for Android. Initially I intended to make the main screen the map itself. After discussion with my boss, it has been decided that I make a normal (non-map) layout as my first screen and then have a button to access that map.
I have the first screen ready to be used. The name of this activity is LocateActivty.java. The name of the map activity is MainActivity.java. Since I initially developed the map activity first, it obviously continues to be opened as the first screen.
What changes should I make to the files (if any) and to any configuration files to make LocateActivity.java my main activity?
EDIT - Manifest code
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.aquamet.saramap.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.aquamet.saramap.LocateActivity"
android:label="#string/title_activity_locate"
android:parentActivityName="com.aquamet.sara.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.aquamet.sara.MainActivity" />
</activity>
</application>
The lines of XML in the manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Need to be moved from the Activity tags for MainActivity, and put inside the tags for LocateActivity. This will then mean that LocateActivity receives the Launcher intent when the user opens your application

Android app not showing in "All Apps"

After some changes I made to my app that I made so it would show the activities in a different order, the app icon no longer appears in the "All Apps" screen on the android device. It does, however, show up on the "Recent" screen. I think it has something to do with a configuration error in my manifest file. I would like the ServerChoiceActivity to be the one represented by the icon, and it's what launches when launch it from the recent screen, but the fact that there is no icon on the "All apps" or "Downloaded" pages confuses me quite a bit.
The application section of my manifest file:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true">
<activity android:name=".ServerChoiceActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<data android:mimeType="image/*"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".ServerSettingsActivity" android:screenOrientation="portrait" android:label="#string/settings_title">
<intent-filter>
</intent-filter>
</activity>
<activity
android:name=".ImageShareActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="image/*"/>
</intent-filter>
</activity>
<activity
android:screenOrientation="portrait"
android:name=".MultiImageUploadActivity"
android:taskAffinity="test.affinity"
android:label="#string/multiupload_title">
<intent-filter>
</intent-filter>
</activity>
<activity
android:screenOrientation="portrait"
android:taskAffinity="test.affinity"
android:noHistory="true"
android:label="Bucket"
android:name=".BucketActivity">
<intent-filter>
</intent-filter>
</activity>
</application>
Any suggestions? The app works as expected when I launch it, and it was working fine, including showing the icon before I modified the manifest file.
Possibly because you have this in your ServerChoiceActivity intent-filter:
<data android:mimeType="image/*"/>

Splash screen problem?

Hi I have created a splash screen but I am not sure how to get it to start. I have tried putting it in the top folder but I can't get it to start, I realise this is because it is the last item I created on my app.
How do I get it to the top of the build path.
Have you placed your Splashscreen in your manifest.
Should place your Splashscreen as the first activity and then the main activity.
For eg:
//First Activity as Splashscreen
activity android:name=".SplashScreen"
android:screenOrientation="portrait"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//Splashscreen activity ends here
Your main activity followed by remaining activities.
<activity android:name=".Aptv"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
<intent-filter>
action android:name="com.ayansys.aptv.Aptv" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

Categories