Home key will not open last activity - android

When i press Home key and then application Icon then it will show me last activity but it will always start the first activity that is from main->first activity.Where main is the launch activity.But if i restart the application then it will work perfectly.So can anybody know why it will work after restart and not at starting?
My Application flow is like this way.Application class->Main activity->Tab activity with5 tabs and each tab open separete activity.edit I restart application like this way: in eclipse again run the application and in phone from settings->application->manage applications->myapplication->force close.Then click on application icon. Sipdroid is launch activity and welcome is first activity which has 5 tabs.
This is my menifest.xml file

Its solved by just removing the android:launchmode="SingleInstance" tag from manifest file.

Related

Android app navigates to launch activity when coming from background

I have 3 activities ( say A, B, C were A-is the Launch activity). When I press home button when at activity C, app goes into background. After that, I took my app through all apps list menu. At that time, my launch activity is showing (activity A). When I press back button, It goes to previous activity (C). I want to retain in the same activity (C) while coming back from background. When I run application through Eclipse, It works fine. But when I send Apk file through mail and run it in device, It fails (previous problem occurs ).
I tried with
android:launchMode="standard"
AND
android:alwaysRetainTaskState="true"
in my launch activity (Login activity or A). Any body please help me, Thanks in advance.
Follow following steps to insure that you are following the right practice:
1. Make sure you are using finish(); on the Activity A or B if you want to finish it and dont if you want the back button functionality.
2. Try Implementing onpause() and onresume() even if you are not going to perform any functionality in them. Use super() for them there.
3. Also, in android when you start an activity by clicking on the icon instead of resuming it from already running activities, it exhibits a different behaviour.

Android app: managing activities

I am trying to learn android programming. I have made a basic app. It has a main activity, a settings activity and a notification that opens the settings activity on click. Main activity also has a settings button that opens settings activity. It may sound weird but i am trying to learn only.
So the problem is when i open the settings activity and then click notification, it again opens settings activity on each click on notification. Then when i hit back button on my phone, it takes me again to settings activity and i have to press back button as many times as i clicked the notification to go back to main activity. Looks like the settings activity is being instantiated again and again on each click on notification. I have tried using many things i read online like trying some Intent flags but can't find anything working. I tried using finish(); in onBackPressed in my settings activity but doing this takes me to main activity and when i hit back on main activity, it takes me to settings and then again i have to hit back that number of times.
How do i make the notification open the settings activity only if its not running?
I think this can help you.
Edit in AndroidManifest.xml
<activity android:name=".SettingActivity" android:launchMode="singleTask">
This will open the activity if its not running.

How to restart app when a sub activity start from recent list in android

My app has two activities.
Main Activity : singleTask
Sub Activity : singleInstance
When launching app with touching app icon, main activity starts. And go to sub activity then press home button. Then Kill app using task Killer. It is a point that I want restart app when user select app from recent list, but app starts from subactivity. I tried to set clearTaskOnLaunch on main activity but it doesn't work.
Does Anyone know how to solve this problem?

Relaunching Activity again?

I have three activities A->B->C.when i am in B activity i click the home button and put the application to back ground(B->home).
When clicking on the my application icon in the home screen the Activity A is opened not activity B .but upon long pressing the home key,its showing that my app is running in background and clicking the icon open the Activity B as expected.
What was the problem?i didn't handle any home key event.How to prevent relaunching my application.
When you make a long press the dialog shows recently used app and not the ones ruuning at the moment. To make sure your activity is not killed go toSettings-> Applications-> Manage Applications -> Running tab.
Usually the behavior you described is cause by launchMode attribute in the manifest.
Check that you do not have anything there.
read more about "launchMode" attribute here.

How to prevent custom home launcher app restart activity?

I am working on my own home launcher replacement and it works fine but one thing bothers me. When I press a home key, current home activity (the one defined in manifest as main/defualt/launcher/home) restarts - current activity instance onpause is executed and oncreate is fired again, so new activity is brought up.
On the other hand, ADW launcher and LauncherPRo does not behave like that - I do not a refresh like in my case. Launcher Pro even can do several actions:
If you are on the main screen with app icons, it zooms out to see a snapshot of all screens,
If you open a drawer and press Home, it just go back to the main screen.
Any ideas how to do that?
I just did a very simple prototype from scratch with just one activity (defined in manifest as main/defualt/launcher/home) and I see the same thing - it gets recreated if I press Home.
Add
if (!isTaskRoot()) {
finish();
return;
}
to the onCreate() of your first Activity (see Android application restarts when opened by clicking the application icon).
Add android:launchMode="singleInstance" to your <activity> element in the manifest.

Categories

Resources