My app consists of 2 activities:
<activity
android:name="com.domain.android.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.domain.android.AboutActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I open my app, navigate to second screen, then go to the homescreen. From there I launch the app again - and it starts the main activity. But the app is running, it is just in the background, but why it didn't open the second activity? I guess it is something connected with activity's category. But how to fix that? Thanks.
Welcome to the ever-growing list of developers who have been bitten by this Android bug. Please see Re-launch of Activity on Home button, but...only the first time for all the gory details. And please go to Google Code and star the issues. We need all the noise we can make to get these fixed.
Hold your home button it will show the running apps click on your app it will open the activity from where you left. even if you click on the application launcher it will open the activity from where you left.
your application will not be in the same state sometimes if android needs resources it might end that activity. open an application move to next screen and press the home button and launch again it will open from where you left do the same with 5 or 6 apps then try launching the 1st app it will not be in the same state it will launch from the launch activity but any app you come to home screen and launch immediately it will open from where you left. If the background app is not doing anything android might end it if it needs resource. correct me if i am wrong. additional information i will be happy to know.
One issue may be that you have 2 activities designated as the main activity using:
<action android:name="android.intent.action.MAIN" />
You will probably have two icons in your launcher for your app. Each one will launch a different activity. You might be launching the first one again and again by using the icon for the first activity. Try removing
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
from your AboutActivity activity declaration. This might fix your problem.
Related
I am building an Android application that launches 3rd party applications - both of which run in full screen.
When the 3rd party application is launched, if i swipe up from the bottom, i see the Android navigation bar (good) - however, if i then press the Android Home button on this nav bar, the 3rd party application exits (good), but my application is returned to the main boot activity and not the activity from which i launched the application from.
My application manifest contains..
<activity android:name=".boot.BootActivity"
android:configChanges="keyboardHidden|locale|layoutDirection"
android:excludeFromRecents="true"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateAlwaysHidden">
<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>
<activity android:name=".main.MainActivity"
android:configChanges="keyboardHidden|locale|layoutDirection"
android:label="#string/title_activity_main"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateAlwaysHidden" />
The BootActivity performs a bunch of pre-loading and model generation before waiting for the user to select a button which starts loading MainActivity which displays the menus and synopsis for the 3rd party apps.
When 3rd party is launched, we swipe up and press Home on the Android nav bar, the logcat is getting both "android.intent.action.MAIN" and "android.intent.category.HOME".
As mentioned above, this is causing the app to return to the boot activity - but i would like the 3rd party app to exit and return to the apps synopsis in MainActivity.
Can intent-filters be added, removed or temporarily disabled programmatically?
Generally using these special launch modes (singleTask) is a bad idea. If your BootActivity is launching HomeActivity, then this will not run in a new task, even though the launch mode would imply that, because these activities both have the same taskAffinity. If you really want to have them run in different tasks, then you need to set the taskAffinity of one or the other (or both) so that they are not the same. Read a bit about how taskAffinity works.
I have installed the app programmatically through other application. Now if I click the application icon in home screen it should not open the app. App can be only able to open while clicking through the app I installed. Can Anyone hep on this. Thank you.
Usually the start activity looks like this in the AndroidManifest.xml:
<activity
android:name=".LaunchActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.categor.LAUNCHER" />
</intent-filter>
</activity>
Now, if you remove the <intent-filter> part, it will not have an icon on the home screen.
Finally, you can follow this StackOverflow answer about how you can open your activity from another app: https://stackoverflow.com/a/2210073/1395437
I'am using Android Studio and I have developed an Home Application by adding
<activity
android:windowSoftInputMode="stateAlwaysHidden"
android:screenOrientation="landscape"
android:launchMode="singleInstance"
android:stateNotNeeded="true"
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY"/>
</intent-filter>
</activity>
This is working and I am testing my application with run button no problem.
But after run another app from Android Studio the home application stop appearing home button selection screen.(not everytime). This is how I solve my problem
I create another application
Move files and codes to new created project.
Then my code is working with different name
This looks like a bug, I dont know what is that. Is there a way to clear cache data or another simple way to solve the problem or any suggestion?
You most likely have a different launcher set as default launcher.
In the settings of your device you should be able to set the default launcher.
Go to applications and look for your current launcher. Clear the default launcher.
If you cleared the default launcher and correctly installed your launcher, it should now ask every time which launcher to launch when you hit the home button.
Tip: Try it out on different devices and emulators!
In some situations (I do not know exactly what causes this to happen),
if I start my app, open another (here AaaActivity) activity and then click the home button to get to the phone home view, and then click the app icon from there, it starts in the application home view, instead of starting in the last open activity.
Why is this and what do I need to do to make it return to the last used activity (AaaActivity)?
Here is an excerpt from the manifest:
<activity
android:name="x.y.app.android.SsssActivity"
android:theme="#style/NoTitleBarNoBackground">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="x.y.app.android.AaaActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="#string/activity_videoview"
android:launchMode="singleTop"
android:screenOrientation="sensorLandscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="x.y.app.android.AaaName" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Multiple tasks can be held in Android OS in the background at once. However, if the OS is running many background tasks at the same time, the system might begin destroying background activities in order to recover memory, causing the activity states to be lost. This is OS design and you can't prevent it. What you can do is saving your state so that you can retrieve it next time. Tasks in Android
I have already finished an Android lock-screen app but my teacher asks me to change it into an app using Windowmanager so that users can not exit the app using HOME button. The idea is that we can make the whole app be a float full-screen window. But I don't know how to change a finished activity into a float window.
You just can't override the HOME button (or "make the HOME button unwork").
There was a time, about in Android 1.6 when you could do that, against Google's wishes. But now you just can't.
Think about it. If you could do that, some app you downloaded from the PlayStore could do that and render your phone unusable.
The closest you can get is adding CATEGORY_HOME as an intent of one of your activities. That way when the user touches the HOME button, he will be presented with the option to choose which activity will open when they touch HOME.
Here you've got an example on how to do it (you don't have to change anything in the Activity classs):
<activity
android:name="com.mpascual.example.HomeActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This line is the relevant one (everything else is just an example):
<category android:name="android.intent.category.HOME"/>