Can I change the default launch activity for an app - android

I am making changes to an app which necessitate changing the default launch activity away from the old default to a new one which is becoming a landing page for my app. Basically I'm just updating the manifest.xml to add the new activity and move the intent filter over from the old one:
<activity
android:label="#string/app_name"
android:name=".NewActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".OldActivity" >
<!-- Launcher used to be here -->
</activity>
Does anyone know if this can cause problems for users who are upgrading from an older version of the app? For example if they have a shortcut to the app, does it still work. Additionally do any of the standard app stores such as Google Marketplace (Play Store) / Amazon etc. have any requirements which mean I can't do this?
I suppose the workaround if the activity must remain the same is I can hack the classes so the old activity points to the new class but if I'm worrying over nothing then I prefer to do it cleanly.

Well basically when you build your application, all the xml that were changed are compiled into binary and are deployed on the device. So if you change the AndroidManifest.xml, when you build and deploy to device (in the development state), the application from devices is updated, and the new manifest is used.
So if you change your application's manifest.xml and build an update for the market, it should work the same, I mean by updating the user application and changing the default activity, because the new manifest binary will be loaded.
Good luck,
Arkde

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

Cant upload my app with Android Studio

I tried to upload a testing app (just blank page) to my phone.
I can see my phone in the list when I press run and there is no new app in my phone and nothing apears there.
why?
thank you.
Firstly, if you app is failing to compile, you will need to check Android Studio for compilation errors. These can be found in the Messages view.
To put your app on a device, your test device will need USB Debugging enabled on it. Please see this answer for more information on how to turn it on should you have missed this step.
If the app is compiling but isn't starting, ensure that you have the following intent-filter within your main activity's definition in your AndroidManifest.xml file.
<activity
android:name=".YourMainActivityName"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This intent filter is how the Android OS works out which activity to launch when the app is freshly opened. Without this filter, no activity will start.

Interact with Android Setup Wizard

I am trying to develop a setup wizard for Android, as I would like to add some functionality to the one existing from Google. Is it possible to somehow interact with the Android wizard? Because when I have searched for information I've seen that not using Google's Wizard might cause some trouble, regarding gmail account activation and so on.
If not, could an activity be called immediately before or after Google's wizard? Would it be enough to just listen to the BOOT_COMPLETED event?
Thank you very much in advance!
I don't know how you will use this unless you are making a rom and can add your app to system but basically you make your setupwizard add-on a Home activity with action MAIN, and categories HOME,DEFAULT. You should also set the priority higher than 1. If any of this is unclear you can look at the Launcher source/manifest that is publicly available.
When your activity is done it should deactivate itself with the PackageManager (setComponentEnabledSetting) and that should be it.
You can add additional activities that start the first time the phone is boot up. You just have to mimic the same behavior as Google's SetupWizardActivity.
Here's the relevant portion in the AndroidManifest.xml for reference:
<activity android:theme="#style/InvisibleNoTitle" android:label="#string/setup_wizard_title" android:name="SetupWizardActivity" android:excludeFromRecents="true" android:launchMode="singleTop" android:immersive="true">
<intent-filter android:priority="5">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
This will allow you to run your application before/after SetupWizardActivity, depending on your priority. I believe higher numbers for android:prioirity run first, but don't quote me on that.
You can find out the AndroidManifest xml for various Android-related apks using apktool. You can even inspect some of apks you picked up from the Play Store or whatever other sources.

"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