I am trying to open my app depending on the url that is entered but in some cases it tries to execute several activities at the same time, is there any way to restrict this so that the MainAction does not execute when trying to execute another?, basically my manifest goes like this
Main Activity
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="http" />
<data android:scheme="https" />
<data android:host="www.test.com" />
<data android:host="m.test.com" />
</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="home"
android:scheme="testapp" />
</intent-filter>
</activity>
Detail Activity
<activity
android:name=".DetailActivity"
android:label="#string/title_activity_detail"
android:launchMode="singleInstance"
android:theme="#style/AppTheme.NoActionBar">
<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="detail"
android:scheme="testapp" />
</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:scheme="http" />
<data android:scheme="https" />
<data android:host="www.test.com" />
<data android:host="m.test.com" />
<data android:pathPrefix="/homes"/>
</intent-filter>
</activity>
the problem is that when i try to open a link like "http://www.test.com/homes" this happens:
Your DetailActivity should be declared as shown below, no intent filter is needed.
<activity
android:name=".DetailActivity"
android:label="#string/title_activity_detail"
android:theme="#style/AppTheme.NoActionBar">
</activity>
The thing that matters is the launchMode for the MainActivity
You should read that : https://developer.android.com/guide/topics/manifest/activity-element.html#lmode
Related
I am working on an android app in that i have added sharing whatsapp sharing feature,I have done it successfully,Now i want to open a specific activity of my android application when user click on link i have shared.I have searched few links but no luck,I hope somebuddy will help me in this.
Added manifest
<activity
android:name=".ProductDescriptionActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="com.abc.allaboutcity.MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</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:scheme="http"
android:host="http://allaboutcity.in"
android:pathPrefix="/allaboutcity" />
</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" />
<!-- Accepts URIs that begin with "example://gizmosā -->
<data android:scheme="allaboutcity"
android:host="allaboutcity" />
</intent-filter>
</activity>
You should add intent filter in your manifest file to activity that you want to open
<activity
android:name="Your Activity"
android:label="Your Activity Title"
android:theme="Your Style">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</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="your url"
android:path="/your path"
android:scheme="http" />
</intent-filter>
</activity>
use this code In Your WebView Activity
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
Webview webView = (WebView) findViewById(R.id.webview_id);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(""+ data);
next, use this code in AndroidManifest.xml, its for all link (Https / Http):
<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"/>
<data android:scheme="http"
android:host="http://allaboutcity.in"
android:pathPrefix="/allaboutcity" />
<data android:host="www.host.com" android:pathPattern="/movie/0.*/" android:scheme="http"/>
</intent-filter>
I want to receive data from other apps. I have ShareActivity class and added it to AndroidManifest but i can't show my app to the share apps list. Please help.
<activity
android:name=".share.ShareActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:noHistory="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
<data android:mimeType="image/*" />
<data android:mimeType="text/plain" />
<data android:mimeType="video/*" />
<data
android:host="www.youtube.com"
android:mimeType="text/*"
android:scheme="https" />
</intent-filter>
</activity>
=============================== EDIT =======================================
Only i removed this line and it worked:
<data
android:host="www.youtube.com"
android:mimeType="text/*"
android:scheme="https" />
specifies Your intent-filter like below code
Try this
<activity android:name=".share.ShareActivity"
android:name=".share.ShareActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:noHistory="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
for information read here
activity
android:name=".activity.rechargetab.RechargeActivity">
<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="mobileleb"
android:host="recharge/checkout/status" />
</intent-filter>
</activity>
When I try mobileleb://recharge/checkout/status from the browser it searches google.Its not working. It does not start RechargeActivity.
add android:autoVerify="true" to intent-filter and specify scheme="http" or "https" or both
<activity
android:name=".activity.rechargetab.RechargeActivity">
<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="http" android:host="mobileleb" />
<data android:pathPattern ="/recharge/checkout/status" />
</intent-filter>
</activity>
I have an application with a single activity:
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:launchMode="singleTask"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="com.google.intent.category.CARDBOARD" />
<data android:scheme="myscheme" android:host="action1"/>
<data android:scheme="myscheme" android:host="action2"/>
<data android:scheme="myscheme" android:host="action3"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
I need it to respond to myscheme:// urls, and it is working in that regard. Unfortunately, it does not show in my App Drawer. If I remove the android:scheme lines, then it shows on the App Drawer, but then it no longer responds to myscheme:// urls, obviously.
How can I fix this activity to make it both show on the app drawer and respond to the custom urls?
Try splitting the intent-filter into two:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<category android:name="com.google.intent.category.CARDBOARD" />
<data android:scheme="myscheme" android:host="action1"/>
<data android:scheme="myscheme" android:host="action2"/>
<data android:scheme="myscheme" android:host="action3"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
I have an Android app that should open links on the app which clicks from the web browser.
I have the following intent filters:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" android:host="www.mysite.com" />
<data android:scheme="https" android:host="www.mysite.com" />
</intent-filter>
And also i checked the my signed sha256 key, package name etc from the assetjson file which is in the mysite/.well-known/assetlinks.json. Everythings looks correct. But the app still not opening when i click the links from the website.
<activity android:name=".YourActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="https" />
<data android:scheme="http" />
<data android:host="mysite.com" />
</intent-filter>
</activity>