Following the suggestions from How to add my browser in the default browser selection list in android?. I have specified my Intent in the manifest file:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http"/>
<data android:scheme="https"/>
</intent-filter>
I have also added the permission:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
But still my browser is not showing in the default app options for the browser category in the settings.
Do I need to do anything else for my app to show up in the default options for browser?
Try to include the <category android:name="android.intent.category.BROWSABLE" /> in your target activity's intent-filter as developer documentation said:
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.
It is required in order for the intent-filter to be accessible from a clickable link. Without it, clicking a link cannot resolve to your app.
<activity ...>
<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="http" />
<data android:scheme="https" />
</intent-filter>
</activity>
.
Additional Tip: (If you want to force your app to be the default browser)
Android App Links on Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler of a given type of link. If the user doesn't want the app to be the default handler, they can override this behavior from their device's system settings.
To enable link handling verification for your app, set android:autoVerify="true" in intent-filter tag:
<activity ...>
<intent-filter android:autoVerify="true">
...
</intent-filter>
</activity>
You need to consider various cases that may be applicable.
Please refer the intent-filters below. Also link is provided at the end.
<activity android:name="BrowserActivity"
android:label="#string/application_name"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true"
android:configChanges="orientation|keyboardHidden"
android:theme="#style/BrowserTheme"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.speech.action.VOICE_SEARCH_RESULTS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- For these schemes were not particular MIME type has been
supplied, we are a good candidate. -->
<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="http" />
<data android:scheme="https" />
<data android:scheme="about" />
<data android:scheme="javascript" />
</intent-filter>
<!-- For these schemes where any of these particular MIME types
have been supplied, we are a good candidate. -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="inline" />
<data android:mimeType="text/html"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="application/xhtml+xml"/>
<data android:mimeType="application/vnd.wap.xhtml+xml"/>
</intent-filter>
<!-- We are also the main entry point of the browser. -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<!-- The maps app is a much better experience, so it's not
worth having this at all... especially for a demo!
<intent-filter android:label="Map In Browser">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/postal-address" />
</intent-filter>
-->
<intent-filter>
<action android:name="android.intent.action.WEB_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MEDIA_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
Look at the different types of intent-filters you might need in order to cover all possible cases.
Refer to this link - complete manifest file of froyo browser.
Consider using CATEGORY_APP_BROWSER with your main filter:
Used with ACTION_MAIN to launch the browser application. The activity should be able to browse the Internet.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.APP_BROWSER" />
</intent-filter>
You can do it with Intent-Filter by making your Activity Browsable.using below code in Android manifest File.
You can do it with Launcher Activity.
<activity android:name="BrowsableActivity">
<intent_filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent_filter>
</activity>
And you must provide scheme as http and https for links to be open with your Application.
As mentioned in documentation over developer.android.com
you need to set intent filer as below
<activity ...>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<!-- Include the host attribute if you want your app to respond
only to URLs with your app's domain. -->
<data android:scheme="http" android:host="www.example.com" />
<category android:name="android.intent.category.DEFAULT" />
<!-- The BROWSABLE category is required to get links from web pages. -->
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
You can achieve this programatically, like this:
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
share.setPackage("your.app.package.name");
startActivity(share);
and also it will be good, if you put a check for the app existence on phone.
Happy Coding :)
In my application i want use deep link for open urls with my application.
I write below codes, but when click on URL open this URLs in browser and not open in my app.
My manifest codes :
<activity
android:name=".activity.PostDetailsActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:screenOrientation="sensorPortrait"
android:theme="#style/DetailsActivityTheme" >
<!-- DeepLink -->
<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="www.example.ir"
android:pathPrefix="/*"
android:scheme="http" />
<data
android:host="example.ir"
android:pathPrefix="/*"
android:scheme="http" />
</intent-filter>
</activity>
My java codes:
Intent intent2 = getIntent();
Uri data = intent2.getData();
if (data!=null){
Toast.makeText(mActivity, ""+data, Toast.LENGTH_SHORT).show();
}
My url : http://example.ir/2018/06/24/content_title_url
How can i fix this issue and open into my app?
I'm searching for a solution to set intent filters for just one file extension. I tried many examples on the web and the following is the only one that worked:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="*/*"
android:pathPattern=".*\\.life"
android:scheme="file" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="*/*"
android:pathPattern=".*\\.life"
android:scheme="content" />
</intent-filter>
The problem is that every file can now be opened with my app, not only the ".life" files. What is wrong in the intent filters? I also tried different MIME-Types and try to add host but then it doesn't work anymore.
I am trying to have my application intercept on a specific URL in browser. following is my code in the Manifest:
<activity
android:name="com.myactivity.RootActivity">
<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" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="subdomian.maindomain.com" />
</intent-filter>
</activity>
it is working fine at the moment, when I open the link http://subdomain.maindomain.com/ , a dialog comes up with my activity listed on it.
but when I add android:path in the intent-filter like below, it stops working, it doesn't even work with simple url without the path.
<activity
android:name="com.myactivity.RootActivity">
<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" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="subdomian.maindomain.com" />
<data android:path="myPath" />
</intent-filter>
</activity>
am I doing something wrong here?
I tested what you said using these links and its working for me
<data android:scheme="http" />
<data android:host="developer.android.com" />
<data android:path="/guide/topics/manifest/data-element.html"/>
And the intent i used is
Intent browserIntent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://developer.android.com/guide/topics/manifest/data-element.html"));
startActivity(browserIntent);
The android:path must match after the host url that you gave for it to work ?
Can you specify what URL did you use ?
Read this link for help
I had developed a video player which is working fine. Now i want from user to play every song with it. I mean whenever user clicks a video file, it should play with my video player or how can I add my video player to the alert dialog which appears when a video file is clicked?
Add the following intent-filters to your video player activity:
<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="rtsp" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
<data android:mimeType="application/sdp" />
</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" />
<data android:scheme="http" />
<data android:mimeType="video/*" />
</intent-filter>
This will add your app to the list of apps that can play Videos and RTSP streams from the internet (remove the first filter if you don't want to support streaming).