I want my application's user to play every video with MyVideoPLayer - java

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).

Related

Manage deep linking and app indexing both simultaneously

In my code below I tried to implement app indexing for Google search result as well as a deep link for some link in my website. But the problem is only app indexing is taking place and no deep linking is being done for the required link.
Is Am I doing something wrong. I tested amazon.in website and they had provided app indexing as well as deep linking for their download app banner.
I had implement deep linking for https://www.website.com/mobile-apps.html, https://m.website.com/m/mobile-apps.html, https://tv.website.com/tv/mobile-apps.html
Below is my code for app indexing as well as deep linking
<activity
android:name="com.website.websiteMobileApp.MainActivity"
android:screenOrientation="portrait"
android:launchMode="singleTop">
<!-- ==================For app indexing================== -->
<intent-filter android:autoVerify="true" android:label="#string/app_name">
<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="www.website.com" />
<data android:scheme="https" android:host="m.website.com" />
<data android:scheme="https" android:host="tv.website.com" />
</intent-filter>
<!-- ==================For deep linking================== -->
<intent-filter android:autoVerify="true" android:label="#string/app_name">
<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="www.website.com" android:pathPrefix="/mobile-apps.html" />
<data android:scheme="https" android:host="m.website.in" android:pathPrefix="/m/mobile-apps.html" />
<data android:scheme="https" android:host="tv.website.com" android:pathPrefix="/tv/mobile-apps.html" />
</intent-filter>
</activity>

Add my browser in the default browser selection list in android?

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 :)

How to fix not show application icon into app drawer?

In my application i want use deeplink. when added intent-filter for deeplink in launcher activity, gone application icon into app drawer!
But when remove deeplink intent-filter show application icon into app drawer.
Manifest codes :
<activity android:name=".Pages.Splash.SplashPage">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- DeepLink -->
<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.com"
android:pathPrefix="/gaming"
android:scheme="http" />
<data
android:host="example.com"
android:pathPrefix="/gaming"
android:scheme="http" />
</intent-filter>
</activity>
when use above codes, not show application icon in app drawer, but when remove below codes from manifest show icon.
<!-- DeepLink -->
<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.com"
android:pathPrefix="/gaming"
android:scheme="http" />
<data
android:host="example.com"
android:pathPrefix="/gaming"
android:scheme="http" />
i want when open users click on link, first start launcher activity, then dynamically open another activity.
How can i fix it?
You should create two separate intent-filters. Try below code in your <activity/> tag:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- 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.com"
android:pathPrefix="/gaming"
android:scheme="http" />
<data
android:host="example.com"
android:pathPrefix="/gaming"
android:scheme="http" />
</intent-filter>
Finally, your code will look as below:
<activity android:name=".Pages.Splash.SplashPage">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- 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.com"
android:pathPrefix="/gaming"
android:scheme="http" />
<data
android:host="example.com"
android:pathPrefix="/gaming"
android:scheme="http" />
</intent-filter>
</activity>

Open .txt attachment from email in Android App

I've defined an intent-filter in my AndroidManifest.xml so that it should show my app as an option to open text files:
<activity
android:name=".Hosts.AddHostActivity"
android:label="#string/title_activity_add_host" >
<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="file" />
<data android:mimeType="text/plain" />
<data android:pathPattern=".*\\.txt" />
<data android:host="*" />
</intent-filter>
</activity>
Then I'm going to handle the opening of the text file like this:
Uri data = getIntent().getData();
if(data != null) {
// Parse text file
}
Although I'm not sure if that's the right way to go about it. Currently my app does not show in the list of apps that can open text files though so I assume something in my intent-filter definition is wrong?
I've updated my intent filter to change the mimeType and add BROWSABLE but still no joy.
<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:mimeType="text/plain" />
</intent-filter>
Turns out mimeType is the best way to go and you don't need the other junk :)

android intent-filter <data> is not working correctly

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

Categories