Asked  6 Months ago    Answers:  5   Viewed   22 times

Say I want to define that an URI such as:


must be handled by my own application, or service. Notice that the scheme is "myapp" and not "http", or "ftp". That is precisely what I intend: to define my own URI schema globally for the Android OS. Is this possible?

This is somewhat analogous to what some programs already do on, e.g., Windows systems, such as Skype (skype://) or any torrent downloader program (torrent://).



This is very possible; you define the URI scheme in your AndroidManifest.xml, using the <data> element. You setup an intent filter with the <data> element filled out, and you'll be able to create your own scheme. (More on intent filters and intent resolution here.)

Here's a short example:

<activity android:name=".MyUriActivity">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="myapp" android:host="path" />

As per how implicit intents work, you need to define at least one action and one category as well; here I picked VIEW as the action (though it could be anything), and made sure to add the DEFAULT category (as this is required for all implicit intents). Also notice how I added the category BROWSABLE - this is not necessary, but it will allow your URIs to be openable from the browser (a nifty feature).

Tuesday, June 1, 2021
answered 6 Months ago

Picasso uses the HTTP client for disk caching and if one is already configured it will use that instead of installing its own.

For the built-in UrlConnection the docs for installing a cache are here:

If you are using OkHttp then you just call setCache:

Wednesday, June 9, 2021
answered 6 Months ago

Don't create your IntentFilter inline, then use the addAction method to add the UNREGISTERED action, i.e.:

IntentFilter filter = new IntentFilter(SIPEngine.SIP_REGISTERED_INTENT);
context.registerReceiver(sipRegistrationListener, filter);
Wednesday, August 11, 2021
answered 4 Months ago

Instead of data android:mimeType="application/customtype", you should use data android:mimeType="*/*". That will catch all mime types that the OS on your device supports. You simply cannot define custom types which the OS doesn't know about.

Saturday, November 13, 2021
answered 2 Weeks ago

After a full day scouring the internet, I finally found a solution. To get a "Nested Master Details Flow" effect simply use a ViewPager with FragmentPageAdapter. The Master Detail Flow will look like this:

enter image description here

To change to a two panel mode when the user switches to landscape, in your extended FragmentPagerAdapter class, override the following method:

public float getPageWidth(int position) {
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    // if the width is greater than 900dp halve the width of the page
    if ((metrics.widthPixels / metrics.density) > 900) {
        return (0.5f);
    return super.getPageWidth(position);

To provide an "up button" for the view pager:

viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    // This method will be invoked when a new page becomes selected.
    public void onPageSelected(int position) {
        if (position == 0) {
        } else {


You can tell the "up button" to go back a page like this (where viewpager is a member variable of your activity, holding the a reference to your ViewPager):

public boolean onOptionsItemSelected(MenuItem item) {
    int position = viewpager.getCurrentItem();
    if (position > 0) viewpager.setCurrentItem(position-1);
    return true;


ViewPager with FragmentPagerAdapter

Display back button on action bar

Multiple-View ViewPager Options

How to implement a ViewPager with different Fragments / Layouts and example github project

Friday, November 19, 2021
answered 1 Week ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :