When I test instant app it works properly but after uploading on Play Store when I click on "Try Now button" app crash.
Here is my code when I click on Try Now button:
package com.journaldev.androidinstantapps.feature;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class ActivitySplash extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashfeature);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://quickeselling.com/splash"));
intent.setPackage(getPackageName());
intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(intent);
}
}
In manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.journaldev.androidinstantapps.feature">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application>
<meta-data
android:name="asset_statements"
android:resource="#string/asset_statements" />
<activity
android:name=".ActivitySplash"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://quickeselling.com/preview" />
<intent-filter
android:autoVerify="true"
android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="quickeselling.com"
android:pathPrefix="/preview"
android:scheme="http" />
</intent-filter>
<intent-filter
android:autoVerify="true"
android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="quickeselling.com"
android:pathPrefix="/preview"
android:scheme="https" />
</intent-filter>
</activity>
</application>
</manifest>
In URL mapping I have opened my main app through URL from splash.
Here is the URL mapping image.
I tried a lot but din't know what's wrong. Please help me to solve this issue. Here is the crash log:
Clicking try now works and your ActivitySplash is launched. As you can see from the stacktrace, the crash happens from the second intent you launch yourself within onCreate. The problem is that you're specifying package on the intent
intent.setPackage(getPackageName());
Since your application isn't installed, Android won't find anything to match this intent.
If the Activity you want to launch is in the same module, convert this intent to an explicit one by specifying the Activity class. Otherwise, remove setPackage, then Android will load the feature module handling that link and show it to the user (or open that URL in browser, if it can't find a matching feature module)
By the way, if you want to support both HTTP and HTTPS in intent-filters, you don't need to write the intent-filter twice. Just add
<data android:scheme="https" />
to the existing HTTP intent-filter, and both schemes will match your Activity.
The URL you are trying to launch from your instant app's ActivitySplash: https://quickeselling.com/splash is not supported in your instant app (at least not from the feature manifests you have shown). The feature manifest you have provided only supports /preview.
So yes, the exception is correct, no activity will be found to handle this intent/URL.
Now, you've got a screenshot that shows your com.android.application module supporting the /splash URL. However, your application module is not installed as part of the instant app, it only gets installed when the user installs the full app.
Nothing from the application module can be accessed from the instant modules during its state as an instant app, if you were thinking otherwise.
You will have to move the activity that supports /splash to one of your feature modules for this to work.
This will help you understand a bit about the structure of instant apps: What dependencies should one be putting in each module of an instant app?
note: there should have been no way for this to work when you were developing from studio, unless you were unknowingly running it as an installed app instead of an instant app (which looks to be the case, from that screenshot, showing app as the selected run build).
Related
I have some problems with intent filter of dynamic link.
I use Firebase Dynamic Link for deferred deep linking, so I add intent filter in my activity at manifest file.
I already use custom scheme and add dynamic link scheme after my custom scheme in same activity.
It works fine when I launch app first time and keep that first instance.
In that time, when I click dynamic link at samsung note app, my app and chrome browser are listed in chooser intent.
But after some hours without using my app so system restart my app when my app bring to foreground, my dynamic deep link intent filter not working.
In this time, when I click dynamic link at samsung note app(I think it works with implicit intent), my app doesn't listed in chooser intent and also can't receive intent filter of dynamic link.
But in same time, my custom scheme deep link working well.
Only dynamic deep link scheme not working.
And also something strange one is that it only happens in my product flavor's release mode app.
I have another flavor for develop so that flavor package name is my origin package name + ".develop" and it's debug mode.
I do same thing in same time, my develop app's dynamic deep link intent filter working fine but only my product app doesn't work.
Is this happen relative with release mode or flavor? Or I just did something wrong with adding intent filter? I really don't know why this happen.
+) I test it at real devices, Galaxy Note8(Android 9, Pie) and Galaxy A32(Android 11).
manifest file of activity:
<activity
android:name=".xxx.XxxActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- custom scheme -->
<data
android:host="xxx"
android:scheme="xxx" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<!-- Dynamic link -->
<data
android:host="xxx.page.link"
android:scheme="https"/>
</intent-filter>
</activity>
MY PLIGHT EXPLAINED
I cannot figure out or find out to stop my Activity from launching itself. This is necessary as I am making a dir manager that has intent filter to open any file, in attempt to easily locate and rename it. For instance clicking a file from notification to be opened by my app for renaming.
MY PLIGHT SUMMARIESED
But it makes no sense to run this intent if you are already in my app. Thus I want to programatically stop my app from being a choice in this case.
MY TRIES FOR SOLUTION
I have tried many stuff. Google, android reference on ActivityInfo. I even tried creating my own activity chooser dialog. Which doesnt work 100% accurately. If it did I could simply omit my activity from the list.
I humbly seek assistance.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="jav.android.dir_mgr">
<uses-sdk android:minSdkVersion="12" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:allowBackup="true"
android:icon="#mipmap/app_icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".DirectoryExplorer"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<activity
android:name=".SelectionWindow"
android:screenOrientation="portrait"
android:label="Selection Window"
android:allowEmbedded="true">
<intent-filter>
. <action android:name="jav.android.dir_mgr.SELECT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
You can use EXTRA_EXCLUDE_COMPONENTS to exclude your own application from the list shown to the user. See the documentation which states:
You can exclude specific targets by providing
Intent.EXTRA_EXCLUDE_COMPONENTS. This is to be used only to remove
targets you have control over. A common use case is to hide your app’s
share targets when your users share from within your app as their
intent is likely to share outside your app.
Add Intent.EXTRA_EXCLUDE_COMPONENTS to your intent after calling
Intent.createChooser()
So, from what I understand, you need a way to check if your app is in focus or not. If that's so, try using ActivityManager.getRunningAppProcesses() which will return a list of application processes that are running on the device.
From there you can iterate through processes that are running on the device and check if your app is listed there and that it's of RunningAppProcessInfo.IMPORTANCE_FOREGROUND.
EDIT: I assume you are using pending intents, then you won't be able to check if your app is already running in the above way. Try using a "launch intent" for your app as explained in this answer.
I hope I understood your plight correctly.
One way to solve your problem is to programmatically unregister your activity from listening to a certain intent-filter value. So let's say you have an activity declared as:
<activity android:name=".FileHandlerActivity">
<intent-filter>
<action android:name="you-file-rename-action-name-here"/>
</intent-filter>
</activity>
Do this in your app:
PackageManager pm = getApplicationContext().getPackageManager();
ComponentName component = new ComponentName(getPackageName(),
getPackageName()+".FileHandlerActivity");
pm.setComponentEnabledSetting(component,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
Please let me know if this works.
Phonegap Application lunching Problem
it is manifest file:
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="cedemo" android:host="com.example.shcema.MainActivity"/>
</intent-filter>
</activity>
it is my main activity:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}}
But when I click "Launch Application" link then i get this alert.
please, help me any one.
You missed CATEGORY_BROWSABLE in your intent-filter.
Quote from Android Docs:
Activities that can be safely invoked from a browser must support this category. For example, if the user is viewing a web page or an e-mail and clicks on a link in the text, the Intent generated execute that link will require the BROWSABLE category, so that only activities supporting this category will be considered as possible actions. By supporting this category, you are promising that there is nothing damaging (without user intervention) that can happen by invoking any matching Intent.
So your intent-filter must be like:
<intent-filter>
<data android:scheme="cedemo" android:host="com.example.shcema.MainActivity"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
See more at : Make a link in the Android browser start up my app?
This won't work. because how Android can know which App I've start on this custom URI call?
So you first have to let the android know that a custom URI exists which can receive such calls and then whenever that custom URI is invoked by any app either native or hybrid, OS will automatically forward it to the registered app i.e. able to receive such calls.
Read this Android docs tutorial:
Allowing Other Apps to Start Your Activity
http://developer.android.com/training/basics/intents/filters.html
Here is an example how one app can call other app. Launch an application from another application on Android
And here is custom plugin which makes easier to open another app from the Cordova/phonegap App.
https://github.com/lampaa/org.apache.cordova.startapp
I know this question is asked and answered many times on SO, but I just couldn't get it to work. Here is my manifest file (I have 3 activities, I'm showing the only one that I want to be displayed when associated):
<activity
android:name=".MyActivity"
android:label="#string/app_name"
android:theme="#style/HoloDarkTheme" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.ACTION_SEND" />
<action android:name="android.intent.action.EXTRA_TEXT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.action.BROWSABLE" />
<category android:name="android.intent.action.DEFAULT" />
<data android:scheme="http" />
<data android:host="example.com" />
</intent-filter>
</activity>
When I launch a browser and go to "example.com", my app isn't launched. Is there something wrong with the above XML?
Not sure if relevant, but this activity uses MediaPlayer to play videos. Also, I'm using SDK version 11.
I figured it out. It's simply a case of typo. Instead of this,
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.action.BROWSABLE" />
<category android:name="android.intent.action.DEFAULT" />
I needed to replace "android.intent.action" with "android.intent.category" in the last two lines:
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
I'm adding this answer here because this thread is one of the top hits when googling "intent filter to launch app from http not working". I suppose the root cause for me could also be considered a typo, but I'm going to call it an "Android documentation defect".
There's a line way toward the bottom of this page that breaks down a URI as:
<scheme>://<host>:<port>/<path>
This breakdown indicates that the "://", ":" and "/" will be added for me so I used the following data in my intent-filter:
<data android:scheme="http" />
<data android:host="my.school.edu" />
<data android:path="thingy" />
I then sent myself an SMS with the following text: "my.school.edu/thingy", which was recognized by my SMS client (Hangouts) as a web address, so it made it clickable. However, clicking on it just gave me a choice of browsers, my app was a no-show.
So I removed the host and the path, and my app launched for any link (or at least every one I tried). I put the host back in and it still worked. Put the path back and we're back to not working. On a whim I decided to prepend a slash to the path:
<data android:path="/thingy" />
...et voilà! There's my app in amongst the browsers! So the error in my view is Android's doc that suggests that the slash is inserted automagically. :) It apparently is not.
More Info: I'm using the HTTP scheme because that's what gets made clickable in SMS and email messages, giving me a free ride to that point.
And note that if you specify a unique host (and path), and the user selects "Always" when choosing your app from the list, future taps on your link will bypass that choice dialog and go straight to your app, which is nice.
Make sure you have the internet permission in your manifest.
I doubt that you can override the http scheme to point back to your app.
I am able to deploy my application but for some reason, I am not able to get the icon to display in the pull up menu on the Home page of the OS. Does anyone know what I can do to solve this?
By the way, the application shows up in "Manage Applications" but does not show up as an icon for some reason. Through Eclipse, I am able to start the application after deployment but that's it... After that, I don't have any way to start it because there is no icon. :( Following is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.ApplicationName"
android:versionCode="1"
android:versionName="2.0">
<application android:icon="#drawable/icon"
android:debuggable="true"
android:label="#string/app_name">
<activity android:name=".EntrySplash"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="com.android.ApplicationName"></data>
</intent-filter>
</activity>
<activity android:name=".EntryScreen" android:label="#string/app_name">
</activity>
<activity android:name=".ApplicationName" android:label="#string/app_name">
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
I had this problem as well, i think the fix that worked for me is i separated the intent tag like below
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="com.android.ApplicationName"></data>
</intent-filter>
when i changed my manifest file like that, my icon showed up.
Try getting rid of your android.intent.category.BROWSABLE and <data android:scheme="com.android.ApplicationName"> temporarily, and see if your icon shows up.
Also, on an unrelated matter, I recommend that your uses-* elements be the first children of manifest, not the last. There have been rumors of problems with the XML parsing done by the Android Market, where it wants to see those before any elements.
Had this same issue and found out that one caveat is that this correct intent on the main activity tag:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
has to be in its own intent filter. you may have other items in the main activity's intent filters, and if so, separate the rest out in to a separate intent filter tag right below it. leave the MAIN and LAUNCHER together in its own.
Alot of the answers to this question on SO seem to miss that point.
Hope it helps!
Well it is happening as you are giving two categories name to your launching activity. You launching activity should have only one category name in its Intent filter. But if you also need the Browsable activity then your Launching Activity may have 2 Intent Filters as show below.
You just replace your EntrySplash Activity code with the below code in you Manifest.xml file.
<activity android:name=".EntrySplash"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="com.android.ApplicationName"></data>
</intent-filter>
</activity>
This will sure work for you...
This problem still exists in SDK v2.2. A few more suggestions in addition to the ones above if you want to publish to your phone from Eclipse. Try these if it's still not working and you don't feel like manually publishing. Remove all blank lines in the manifest. And make sure this line just has only icon and label properties in it:
<application android:icon="#drawable/icon" android:label="#string/app_name">
Apparently I found out that it works if I manually install the application using command line adb. So, in case you updated your ADT plugin and you experience problems, just install things manually...
I find that sometimes my assets don't update in the app when I add them to my projects.
There are two ways you can fix this problem:
Clean and rebuild the project.
Uninstall the app on your phone and install it from scratch using ADT.
Simple as that!
Just to add confirmation to CommonsWare's answer, I just came across this exact bug for a project targeting 2.3.3+. I had to Delete the following:
<data android:scheme="com.android.ApplicationName"></data>
Then I had to Clean the project. I think that having to use adb to install every time is a sign of something wrong with the Manifest, and will come back to bite you later (once in the Market specificially).