I created a basic Android app from the Eclipse wizard. I then added the following intent filter to AndroidManifest.xml, after the existing one. This makes it support a custom "sample://" URL scheme:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sample" />
</intent-filter>
If I run Chrome or the default browser, and click a "sample://" link, it launches my app. However, if I look at the task switcher, my app isn't listed. Instead, Chrome is shown, with my app's screen shot.
Why is this? Can it be fixed? I'm running Android 4.2.2 on a Galaxy Nexus phone.
I notice that if I add android:launchMode="singleInstance" to the activity, it opens in a separate app. But the docs say this is "not recommended for general use". Why not?
The reason why you Activity appears in Recent Apps as Chrome is because it now belongs to the Chrome task, because it was launched from there.
As you noticed android:launchMode="singleInstance" solves your problem, however it is not recommended or discouraged because it would brake the user experience and navigation and how users expect your application to behave.
Fortunately, I think there's a way of specifying Intent flags in your HREF, try something like this:
<A HREF="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.example.package/.MyActivity;end" />
in the previous example launchFlags=FLAG_ACTIVITY_NEW_TASK. This flag is generally used by activities that want to present a "launcher" style behavior: they give the user a list of separate things that can be done, which otherwise run completely independently of the activity launching them.
Related
I've just setup App Links within my Android app, following the official Android guides online. I can click on a link and my app launches just fine.
However, I observe different behaviour depending on where the link was clicked from.
From the Gmail app, my app launches and all works well. Clicking the ||| icon at the bottom of the screen shows my app is running standalone.
From Slack, my app launches and works fine, but it appears to be a part of the Slack process. The back button doesn't function, and if I click on the ||| icon at the bottom of the screen then it shows that my app appears to be running inside Slack (there's only one window open).
From WhatsApp, the same happens as Slack.
This is from my AndroidManifest.xml:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="mydomain.com"
android:path="/" />
</intent-filter>
I suspect this is somehow related to Slack opening web links itself, but I don't know how to prevent this. This also doesn't explain the WhatsApp behaviour, as WhatsApp already seems to open web links in Chrome independently.
Any advice would be appreciated!
That's actually the default in Android- your app is launched as part of the caller's stack. You need to set the launch mode to singleTask in the manifest. Please note that this may sometimes cause onNewIntent to be called rather than a standard activity creation path, if the activity is already alive in the background.
For a project I have encountered a very strange issue:
Deeplinks have been working very well for the last year, but recently (since the beginning of January-2019) we have been getting complaints from our users that deeplinks have stopped working (some say 9 out of 10 time).
We have not changed any of this code and have great difficulty reproducing this issue.
Even stranger, in the sparse times that we do encounter the issue ourselves, the android OS does not even show our app as an option through the 'open with'-dialog. This suggest to us that the OS sometimes forgets that the app has intent-filters registered in its Manifest.
Restarting the app appears to fix this and deeplinks start working again.
The app also seems to work every time we do a new build from Android Studio, which makes it very hard to reproduce.
Our manifest has a specific activity that handles deeplinks:
<activity
android:name="com.company.DeepLinkActivity"
android:noHistory="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="ideal-payment"
android:scheme="com.company.ideal" />
<data
android:host="ideal-payment"
android:scheme="com-company-ideal" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="${appLinkIdealHost}"
android:pathPrefix="/ideal-betaling/landingpage"
android:scheme="https" />
</intent-filter>
<intent-filter android:autoVerify="true">
...
</intent-filter>
<intent-filter android:autoVerify="true">
...
</intent-filter>
</activity>
We thought it might have something to do with the autoVerify not being accessible, but then the OS should show the 'open with'-dialog, which does not happen when the issue surfaces.
Is there someone that has encountered a similar issue? Any help or suggestions would be greatly appreciated.
When app is stopped for example with an exception or when user have force stopped it from settings or in some devices when user removes app from history (or from tasks) the app will be force stopped automatically (which is not a good choice from manufacturer) when app is in stopped state its manifest intentFilter will not be used (when app is first installed and never opened also it is in this phase)
While in stopped state, the application will not run for any reason,
except by a manual launch of an activity, or an explicit intent that
addresses an activity ,service or broadcast.
https://riptutorial.com/android/example/30592/android-stopped-state
Most of Android versions you mentioned was 8 or grater thus below quotation also may be useful but this is for services and broadcast receivers.
Whenever an app runs in the background, it consumes some of the
device's limited resources, like RAM. This can result in an impaired
user experience, especially if the user is using a resource-intensive
app, such as playing a game or watching video. To improve the user
experience, Android 8.0 (API level 26) imposes limitations on what
apps can do while running in the background.
https://developer.android.com/about/versions/oreo/background
Can you specify the version of android OS ? because android:autoVerify="true" works only on Android 6.0 and higher to cause the system to attempt to verify all hosts associated with the URLs in any of your app's intent filters.
these two entries also look strange to me, not sure what you are trying to accomplish there:
<data android:host="ideal-payment" android:scheme="com.company.ideal" />
<data android:host="ideal-payment" android:scheme="com-company-ideal" />
this is far from being ideal, because those hosts and schemes are both invalid, see data-element.
I would assume, based upon all the code which obviously had been withheld... that other intent-filter might also feature duplicate data elements, which would need to be moved into separate intent-filter, of which an activity element permits several. set android:autoVerify="true" on all these intent-filter and then closely review the logcat after the package installation.
Great news, we were able to find a solution.
The issue originated from an older version of the Chrome browser.
https://bugs.chromium.org/p/chromium/issues/detail?id=935864
After the release of version 73.0.3683.90 a few days ago, the issue has gone away.
Thanks Google :D
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.
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
I have an Android AIR application (developed with Flex SDK 4.5.1) for which I need to block the Home Button, as the app is used by patients in a hospital without supervision, i.e. it is crucial that they cannot leave the app.
It seems that the only way to hijack the Home Button is to be registered as the default launcher, so that your own app gets the focus when home is pressed. This is easily achieved in the manifest, such as:
<activity android:excludeFromRecents="false">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</activity>
Now the problem is: If I do quit the application, the original launcher should be made available to the user and I think the solution would be to just start the original launcher, but how should I do that? The original Android-way of "intents" is not available in AIR and the navigatetoURL() function seems to work only for special URIs, e.g. "market://.." launches the default market app, however, I need to execute an arbitrary application...
Edit: I am referring to a mobile Android App running in this case on an Archos tablet, but it could run on any Android device with AIR installed, such as a typical mobile phone like the HTC desire. With "home button" I am referring to the respective hardware button that allows the user to switch applications (or, to be more exact, to switch to a launcher app that typically shows all the apps as icons to tap on). This "home button" functionality I need to block, as the user should not be able to easily switch to another application.
This is probably a less useful answer but disabling device buttons sounds like something that should be handled at the OS layer and not at the Application layer. Might want to have a custom build of Android for this purpose.