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

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.

Related

installed application from Android Studio opens another activity instead of launcher activity

Whenever I run my app from Android studio, an Activity having
android:exported="true"
get's launched instead of launcher activity
<activity
android:name=".activity.SplashScreen"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.NoActionBar"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
But once app installed, correct launcher activity opens, no issue.
Only issue happens when I launch my app from Android studio(i.e. by running the app). So why this happens?
Without android:exported="true", on some devices, that activity not gets launched after clicking notification of my app. So is it good to keep exported true?
Also I can't post my entire manifest here
When running the app from Android Studio, you're probably using instant run. which applies the code changes to the current running process of your app, so instead of installing the app again, it applies the new changes to the running app, in that case you see the current running activity as it is.
http://android-developers.blogspot.com.eg/2016/04/android-studio-2-0.html
https://developer.android.com/studio/run/index.html
If it only happens in Android Studio and not when the app is installed, it is most likely a problem with the run configuration. You can access it by going to
Run -> Edit Configurations

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();
}

Mosync application crashes when is launched via notifications. LaunchMode singleTask

I'm using Mosync SDK 3.2.1 to develop a HTML 5 application for Android 2.2, 2.3 and 4.03. I had the issue described in this post http://jira.mosync.com/browse/MOSYNC-2367 . The fix proposed
android:launchMode="singleTask"
solved the "restarting of the app" issue when launching the app from menu but broke the launching behavior of the app via notifications when the app is working in background. (in launchMode="standard", works fine, the app resumes). With this fix it crashes with the message "Unfortunately, Zymbo has stopped" (4.0.3) and "The application Zybmbo has stopped unexpectedly."
If the application is not working in background the launch via notification works fine, the app is started.
This is how the MAIN activity is declared in manifest file.
<activity android:name=".MoSync"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This is how the application behaves right now:
1. Launch the application via menu shortcut
2. Press "Home"
3. Launch the application via menu shortcut (launchMode="standard" => restarts the app BAD / launchMode="singleTask" resumes the background app OK)
4. Press "Home"
5. Launch the application via notification item (launchMode="standard" - opens the app working in background OK / launchMode="singleTask" the app crashes BAD)
What I want to achieve is if the application is running in background and I click the notification or the app icon from menu, i want the application to resume and not to start again.
Any hint is appreciated, Thank you,
Mike

"App not installed" after switching Android app's main Activity to other name

In the AndroidManifest file of my application, the main Activity's android:name has always been:
android:name=".MainActivity"
Recently, I have changed the app to use a library. All the code has been transferred to the library project so that I can offer a free and a paid version, both using the same code (except to some modifications).
Now the name of the main Activity in the manifest file is:
android:name="com.name.library.MainActivity"
Unfortunately, users are reporting now that they cannot open the updated app anymore on their phone. Android says: App not installed!
After some searching, I found the cause for this problem here: You cannot change an Activity's name without causing problems for other apps trying to use Intents for this app. I guess the users who report the problem have placed my app on their home screen and the launcher application doesn't find the old Activity name anymore. Is that true?
But does this also affect the menu with all apps listed? Actually, Android should update the Activity's name on update, shouldn't it?
And how to resolve this problem? My only idea is to create a new Activity with the old name and in onCreate(...), place the following code:
Intent i = new Intent(MainActivity.this, MainActivity.class);
i.setComponentName("com.app.library", "com.app.library.MainActivity);
startActivity(i);
But this is not a pleasant solution, obviously ...
I guess you could also use an activity-alias .
<activity-alias
android:targetActivity="com.name.library.MainActivity"
android:name=".MainActivity"
android:label="#string/label"
android:icon="#drawable/icon">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity-alias>
android:name should match the old activity name
i think you have made your changes in a wrong way. You don't have so many choises: since the moment the user puts a shortcut to your app on his homescreen, the shorcut refers to a specific uri (you.old.package.MainActivity) and i think the only thing you can do is what you said, even if is not a pleasant solution. The other solution is that the users delete and recreate the shortcut to your app, since the moment that when an application changes it-s internal structure, the intent which is launched is always the one with the intent filters
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
declared in the manifest; so re-creating the shortcut will fix the problem.
You should have made the changes in order to let the old project to become the library project, and create the Lite and Pro projects to use the original project became a libray project.
In this way the uri of your activity did not need to be changed

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

Categories

Resources