android menu Home item - android

I'm running my android app on my droid x2 device. this app has a menu with some items, one of which is the Home (the screen that launches when the app starts).
the problem is that when I tap on the Home item it brings up this menu,
I don't know why it does that and how i can fix it.

I actually fix this issue by adding a new activity to my manifest file. so what I had for the launcher activity was
<activity
android:label="#string/app_name"
android:name=".Home" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and I also added the following activity which would act just as a normal activity and in my menu selection I used the action name of this new activity.
<activity
android:label="#string/app_name"
android:name=".Home" >
<intent-filter >
<action android:name="com.mywebsite.app.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

Related

How to make the app as launcher and the only open app in Android?

Is there a way to make my app the only running app in a device, what I mean is the only visible and open app? Once the device booted, the app will launch automatically while any tap to settings at status bar, back, home and recent apps button are disabled. Probably a custom Android OS is required or rooting the device will be enough? We plan to have a set of devices where users can only operate with one app. Thanks
You need to be able to remove current launcher app to the system part of the device.
Then it's as simple as:
Adding android:launchMode="singleTask" to activity tag in AndroidManifest.xml
Adding <category android:name="android.intent.category.DEFAULT" /> and
<category android:name="android.intent.category.HOME" /> to your intent filter
The end result should look similar to this:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.app.MainActivity"
android:launchMode="singleTask"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
</application>

Android:Understanding how does an activity start when application launches

I have pasted the code of my Androidmanifest.xml,how does android decides which activity to launch when application starts ? In this case its the mainactivity. What changes to I need to make if I want to launch AnotherActivity when application launches?
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.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.example.AnotherActivity"
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>
The MAIN element specifies that this is the "main" entry point to the application. The LAUNCHER element specifies that this activity should be listed in the system's application launcher (to allow users to launch this activity).
<activity
android:name="com.example.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>
Just remove the intent filter from the next activity!!
When the user selects your app icon from the Home screen, the system calls the onCreate() method for the Activity in your app that you've declared to be the "launcher" (or "main") activity. This is the activity that serves as the main entry point to your app's user interface.
You can define which activity to use as the main activity in the Android manifest file, AndroidManifest.xml, which is at the root of your project directory.
The main activity for your app must be declared in the manifest with an that includes the MAIN action and LAUNCHER category. For example:
<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>
Based on this, we can conclude that you currently have a faulty configuration. Only one activity can have the Intent filter for Main (so you should remove the <intent-filter> from your .MainActivity if you want to use AnotherActivity as you "Home" Activity).
<activity
android:name="com.example.AnotherActivity"
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="MainActivity" ></activity>
As stated in our conversation, you want to show a determinate action at launch, with is own functions and layout. The solution is to use one Activity which inflate Fragment1 or Fragment2, based on your condition.
Dealing with Fragment is very difficult, but when you will master them, you will have fun. There are few example on the net about Fragment, but i tell you this: read and practice is the only way you will learn something. Copy and paste from other source code / example will not help you. Follow this links:
link 1
link 2 with sample
link 3 for supporting tablets
Good luck!

Android: first activity after background

I get a problem when I running a app and the app goes to background. If I click on app icon again It shows activity mark as LAUNCHER:
<activity android:name=".LoginScreen" android:label="#string/app_name"
android:theme="#style/defaultStyle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
But I want to show last activity active before background. It is something wrong on my AndroidManifest?
write android:launchMode="singleTask" in the manifest

App launcher to reload from beginning in Android

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>

android menu Home item issue [duplicate]

I'm running my android app on my droid x2 device. this app has a menu with some items, one of which is the Home (the screen that launches when the app starts).
the problem is that when I tap on the Home item it brings up this menu,
I don't know why it does that and how i can fix it.
It works fine on the simulator, I'm gussing this is something that needs to be set up on the device.
I need to know if some has seen this menu before and if so what it is and when it shows up?
I actually fix this issue by adding a new activity to my manifest file. so what I had for the launcher activity was
<activity
android:label="#string/app_name"
android:name=".Home" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and I also added the following activity which would act just as a normal activity and in my menu selection I used the action name of this new activity.
<activity
android:label="#string/app_name"
android:name=".Home" >
<intent-filter >
<action android:name="com.mywebsite.app.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

Categories

Resources