simplest app ever not resuming properly - android

I made an exceedingly simple app consisting of a launch activity (.TestActivity) with nothing more than a button on it, and a 2nd activity (.second) with nothing more than a piece of text on it.
Then I create an .apk file from it and sideload it to my phone, I open the app, click the button and go to the 2nd activity, press Home to make the app leave the screen, and then press the icon of the app to open it again, it resumes on my FIRST activity and not the 2nd one that I would expect.
After I force close the app it works properly, though! Where is the problem here? It's not my phone because I've seen this on several other devices that I've tested with. It's not necessarily Eclipse because it works as expected on Eclipse (and the emulator), it's possibly the manner in which I package the .apk file (but even then it's a pretty standard "export" that I'm doing from Eclipse so I'm not sure what that would be). Any other ideas?
Here's the manifest:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".TestActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="#string/app_name"
android:name=".second" >
</activity>
</application>
Why would force closing the app make it work how I want it to work the 2nd time, though?

Here's the deal. In your Android Manifest you identify which Activity you want to load when launching your app. If, for some reason, your app is not resident in the task stack Android will launch that Activity. If your app is in the task stack Android may choose to bring it to the front and you could be looking at whatever Activity was showing when you left the app. The thing is you cannot count on this. If you want the first Activity to show only te very first time the user launches your app you need to set a flag and then on subsequent launches you can automatically launch the second Activity based on that flag.

I just found the following links:
http://code.google.com/p/android/issues/detail?id=26658
and a decent workaround here: Home key press behaviour
I understand what CaseyB is getting at, but I can reproduce this every single time. If my app has a memory leak or ends up getting killed due to inactivity or the need for Android to reclaim some of its resources, that's one thing. But this seems pretty obviously like a bug to me and I'm just going to have to live with the workaround for now.

Related

Android: Correct Way to Change Launcher Activity (Read Fully)

I'm facing the following issue. I have an app with an established user base, and I wanted to change my default launcher activity for the app.
The problem happens only for some users that updated the app via Google Play. Problem does not occur when running via Android Studio.
The problem comes into play with some of the users' Launchers on their phones. After they update the app, and when they try to open the app from their homescreens some users get "Error app not installed" or "Activity does not exist" errors.
It seems that on some users' devices, the OS launcher adds additional information about the activity name and this causes an issue after they update the app.
What's the correct way to change the launcher activity in order to avoid the problem I described above? This is quite an issue as a lot of non-techy users just uninstall the app.
Previously .TabHostActivity was set as Launcher/Main
After making .SplashActivity as Launcher/Main and rolling out the update to Google Play, some users started receiving "App not installed" error when opening the shortcut from their homescreen. App still works if they open it via App Drawer, but the shortcut on the homescreen gives this error.
Code:
<activity android:name=".SplashActivity" android:screenOrientation="portrait" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TabHostActivity" android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
Make TabHostActivity Launcher activity again.
In TabHostActivity at first check if it has been opened from SplashActivity (You can add a flag in the intent while starting the TabHostActivity from SplashActivity and check the same flag in TabHostActivity)
If TabHostActivity has not been opened from SplashActivity, then redirect to SplashActivity.
All of the above should be coded before any other code in OnCreate of TabHostActivity.

How to open the application from push notification without creating another instance of the app?

In this question I asked how to open a fragment in my application from a push notification. I found the solution pretty easily, but now I'm faced with the problem that when I follow the push notification, another instance of the application is created.
I tried the suggestions given here, but adding noHistory="true" to the activity in the AndroidManifest file, caused the app to close when I didn't want it to close.
Following the steps below, I need all instances of the app to be closed at step 5. In fact, I need to not be creating a second instance of the app at step 4. How do I do this?
Open the app from applications menu -> see screen A.
Navigate from screen A to screen B.
Push notification arrives!
Open notifications drawer, follow notification into the app, see screen C.
Press the device's hardware back button until prompted to exit the application - say Yes!
See screen B -> where you were when you opened the notification!
This shows that a second instance of the application is created when you follow the notification while being somewhere in the application.
Why?
And how do I kill the first instance of the application, or kill both instances of the application when prompted to close the application and saying Yes?
Or better yet, how do I NOT create two instances when following the notification into the app?
I maybe a little late, to avoid the creation of a new instance of your activity you can add a "launchMode" in the AndroidManifest like this:
<activity
android:name=".MyActivity"
android:label="#string/app_name"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Went the notification is open the singleTop will bring the current instance of the activity instead of creating a new one.
See this link for more information about launchModes: http://www.intridea.com/blog/2011/6/16/android-understanding-activity-launchmode

Application is not installed error, when launched from home screen shortcut

FYI: I have gone through these links already
'App not Installed' Error on Android
Application not installed when i try to autoupdate
My question is little different.
I released app with default/main activity as XActiivity.java in version 1.0
I released update with changing default/main activity as YActivity.java
I find that app opens fine from application meanu, but when I try to launch from home screen shortcut, it throws an error saying "Application is not installed"
I know that its due to shortcut referencing to old XActivity.java, by removing would solve this issue, but if I release app to thousands as an update who already have this app would get annoyed at the first instance of this error message. I would loose on good reviews I got
Please check if you have the property android:exported="false" on an activity that should have been a "android.intent.category.LAUNCHER". This disables the specific activity from being launched on the launcher.
in 2021,
just add
android:exported="true"
in the manifest, and it will be fixed
That is because homescreen shortcuts work slightly differently from the launcher icons in some launchers.
Your old shortcut still contains a reference to XActiivity as the main Activity, when you have updated it to be YActiivity. This causes Android to think the app isn't installed, as it cannot find an XActiivity in your app marked as the MAIN Activity.
Simply removing the home screen icon and adding it back will solve this.
Putting
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
inside specific activity inside Manifest.XML did the job for me.
This question is old, but still relevant today.
This occurred because I changed the starting activity. I had this originally (truncated):
<manifest>
<application>
<activity android:name=".activities.StartActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.OtherActivity"
android:exported="false" />
</application>
</manifest>
I removed StartActivity but I forgot to remove android:exported="false", after adding the intent filter. It looked like this:
<manifest>
<application>
<activity
android:name=".activities.OtherActivity"
android:exported="false"> <!-- REMOVE THIS -->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In short, make sure your starting activity is exported.
What if you implement both XActivity and YActivity as entry points in your app? XActivity could remove its launcher shortcut, install the YActivity shortcut, and launch YActivity.
first ensure if current installed apps can be moved to sd card
if they cant be that is it you have got the reason
on my htc desire 300 while rooting i flashed wrong rom bricked my phone in bootloop
got it repaired from a shop
now running custom rom i dont know which one
but it doesnt support moving app to sd card
so i copied app to phone memory
unmounted or removed sd card
then i try to install from phone memory and my fs2014 1.35 is now installed
horrray
hope it help you
this will only work if you have custom rom because original rom does nt have errors like that
or you call that a bug
Possible Solutions of “Application not Installed” error
Reboot the phone: In times like this, first thing to do is to reboot
your device. Or just shut down, remove and reinsert your battery.
Make sure to uninstall any apps you don’t use to free up space, also
uninstall previous versions of the same app currently installed on
your device.
Double check the apk files you download and be sure they were
completely copied or downloaded.
Try resetting app permissions by going to Settings >Apps>All>Menu key
Reset application permissions or Reset app preferences.
Change app installation location to Automatic or Let system decide.
Make sure your SD card is not mounted or connected to a PC or
elsewhere.
For worst case scenarios, format your SD card – copy it’s contents
somewhere else for backup and format.
The last solution would be to totally wipe your device. Either by
doing a factory reset under Settings or by doing a full wipe in
recovery mode.
Reference
I've had the same problem, just a minute ago.
I'm not expert so all I could get from all answers is problem is in shortcut created on home screen by launcher.
I'm using classic minimalist launcher which doesn't have app drawer so all apps are on home screen, so I can't just delete shortcut without uninstalling it.
So I cleared cache of my launcher and it created new shortcut for that app on its own and it started working.
Might be a case, check your code for "App shortcut creation" where the Intent.EXTRA_SHORTCUT_INTENT is mapped to the LAUNCHER activity. (Might be SplashScreenActivity)
The solution I wrote is.
AndroidManfest.xml
I retained intent filter android.intent.action.MAIN for my previous XActivity.java.
I also retained intent filter android.intent.action.MAIN and also category as LAUNCHER to YActivity.java
In the onCreate() method of XActivity.java I added these lines, and it seems to have solved issue
Intent thisIntent = getIntent();
if(thisIntent.getAction() == "android.intent.action.MAIN"){
Intent intent = new Intent(this,YActivity.class);
startActivity(intent);
finish();
}

Eclipse Android launcher shows home screen, not my application

When I launch my android application from eclipse, it shows the home screen, and I then need to unlock the screen and go to my app. I would like it to just show my app by default.
I have tried right clicking on the app and selecting Run As..., but Android Application is not a choice there. I need to manually create a new Android run configuration for my application and then I launch that.
Is there a way to just make my app show by default? I'm running with the emulator for Android version 2.2?
Note: I'm also getting an error that says "Emulator] Unknown savevm section type 95" which I'm not sure what that means yet
thanks,
Jeff
The emulator always starts with the screen locked. Unlock it and wait a moment, sometimes it needs a minute to launch your app. If it doesn't work after a few moments, leave the emulator open and try running it again. If it doesn't launch now, there's something wrong.
I'm thinking you either didn't create your project as an android project to begin with, or if you did you didn't create a starting activity (or deleted the one that you did create)? Either way, you probably need to go edit your AndroidManifest.xml file and add an intent filter to an activity. Just guessing. Should look similar to this:
<activity
android:name={String for the name of your app}
android:label={String for the name displayed on the icon}>
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
** posted before your edit ^^^
In terms of your error, I have no clue what that is, so maybe it has nothing to do with your AndroidManifest, then. :T
Check your manifest, and make sure your activity has the correct intent-filter
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
BTW, Previous to Android 1.6 i think the emulator always started with the screen locked then they changed that and it starts with your app

Activity history stack wrong upon first install on device?

Edit / Update:
As an update to the below problem, I found the exact action which causes it to happen.
Download an apk from a url through the android browser
Install the app.
After install, the app gives you two choices: "Open" or "Done".
If you choose "Open", the quirky behavior described below starts.
If you choose "Done", then launch the app from the app tray, it works fine.
So it seems like this problem is caused by using the "Open" button the browser provides you after installing the APK.
I'm experiencing an error in the history stack of applications upon first install. I made a test app to demonstrate this.
The test app is simply two activities, A and B. Activity A launches B. That's all it does. Rest is wizard generated template code from eclipse.
When the user installs the app (via web url apk), and runs it for the first time, I get an out-of-order activity stack:
User starts the app, A is on top.
They make A launch B by clicking a button. B is on top of the stack.
User hits the home screen button.
User returns to the app, A is displayed, instead of B.
User hits the back key, B is shown!
User hits the back key again, A is shown!
User hits the back key again, home screen shown.
Now the stack is clean, and app behaves "normally" from now on!
Is any one else seeing this? This is almost exactly like this known bug, however my users are not installing from eclipse:
link.
I can provide the test app/source if anyone wants to try. This is the manifest, which does not have any special customizations made to it.
<activity android:name=".ActivityA"
android:label="ActivityA">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ActivityB"
android:label="ActivityB">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
As far as I know, this should definitely not be happening, and works fine after you clear the history stack the first time.
Thanks

Categories

Resources