Hello I am fairly new to Android App Development and was looking at some example code here. I understand that the manifest xml here states that by pressing the app to launch the map but I wanted to implement a login as well. I was wondering if anyone here had any advice in terms of how popular apps format this? Do they have a login as their launcher or the application itself? Thank You!
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It seems you look to change the launcher activity
<activity android:name=".LoginActivity" android:label="#string/title" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You can put the login activity that way
Related
Ran into this issue trying to get Interstitial Ads to work on my first android app. Being a complete novice I really had on idea how to add the "useClientJar" flag to the Intent Extras.
This wasn't the issue, it's actually an error in the AndroidManifest.xml and I'm posting this question/answer because it's one of the few situations I've run into with only 5 relevant google results, the top one being a piece of IRC chat with one poor guy running into the same problem as me.
The issue is that I had foolishly made my main activity into the AdActivity in the AndroidManifest.xml like this:
<activity
android:name="com.google.android.gms.ads.AdActivity" <!-- notice this name, this means the interstitial ad is now the main activity! -->
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The fix of course was to correct this like so:
<!-- They are now two separate activities -->
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" />
So, in a previous version of my Application, I had an entry point named MainActivity
<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>
This version, I have a new entry point for my application, which then re-directs to MainActivity or another screen programmatically. Here are the two activities:
<activity
android:name=".NewEntryPoint"
android:label="#string/title_activity_second" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I removed the action.MAIN from main activity and set it to my NewEntryPoint. However, any users that had the application as a shortcut on their homescreen will lose the shortcut. Keeping the Launcher category in MainActivity didn't help either.
Is there a way to change entry point of my App without removing shortcuts?
Thanks!
I believe you could use activity-alias for this, but I would question whether or not it's worth the future maintenance just to avoid users having to add a shortcut to your app again. Something like this:
<activity-alias
android:name=".MainActivity"
android:targetActivity=".NewEntryPoint">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
My project currently has just two classes and when I run the project on my phone two apps are created. The first app runs the entire project and the second app only runs one class(The class that isn't my Main). Has anyone encountered this bug before?
Maybe you have multiple activities defined as launcher activities in your manifest, like so:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AnotherActivity">
<!-- creates a second "app" when deploying -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
That would create two apps on your phone.
Yes, 'Jaap Van Hengstum' is correct.
If you want only one entry point for your application, then only one activity should have below intent filter.
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Remove if you have multiple entry of it in your manifest file.
I have created app to act like an home launcher. So when user clicks on the home button I get Complete action using Launcher or my app's name say for example "myhomelauncher".
When I click on home button and click myhomelauncher my application loads everything from first perfectly fine. Now when I am in the second screen in my application say I am looking at activity 2 in my app and now I click on Home button and click myhomelauncher I endup getting the same activity 2 windows it is not reloading. (It should reload and show up activity 1 rather than 2)
I have seen lot of apps that can reload everytime I click their launcher. Why not mine?
Here is what I have done in my manifest.xml
<activity
android:name=".MyLauncher"
android:label="#string/app_name"
android:persistent="true"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I am not sure where is the mistake?
Please have a look into the documentation - what can be of interest to your problem are the following settings:
android:clearTaskOnLaunch
android:launchMode
I would suspect setting android:launchMode to singleTask could solve your problem, altough be careful which side effects this will cause.
So:
<activity
android:name=".MyLauncher"
android:label="#string/app_name"
android:persistent="true"
android:screenOrientation="landscape"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
should do the trick.
Look up launchMode. But be careful, with great power, comes great responsibility.
This is the relevant section in a menifest that seems to work for me. Note that I have put singleInstance in the launch mode because I don't want more than one of my app, ever.
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".usbEffects"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"
android:screenOrientation="portrait"
android:launchMode="singleInstance"
android:configChanges="keyboardHidden|orientation"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
My problem is thus; I am new to programming on the ANDROID platform and have a 'working' application that piggy-backs on the API-Docs example. I wish it to launch three tabs one containing a list of reports, one a form to file a report and the last to show the geo-located reports. It doesn't appear as a separate application, it instead appears as a list to be launched by the API-Docs example. Below is my manifest code...
<activity android:name=".HelloFlamingos">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".Controls2" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity android:name=".List1" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity android:name=".ReviewTab" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
HelloFlamingos is the initial page that I wish to be displayed, I realise that the intents for this are wrong, have thought about using category: VIEWS, action: DEFAULT, however is seemingly unwilling to work. Thanks!
In what context is the activity started? If you're looking to have the HelloFlamingos activity the first displayed from the Android OS, you should change its category in the manifest to category.LAUNCHER.
If you're looking to start the activity from elsewhere in your app, create an Intent which matches what you've specified (category.SAMPLE_CODE) and use startActivity or startActivityForResult.