Example usage for android.net Uri getHost

List of usage examples for android.net Uri getHost

Introduction

In this page you can find the example usage for android.net Uri getHost.

Prototype

@Nullable
public abstract String getHost();

Source Link

Document

Gets the encoded host from the authority for this URI.

Usage

From source file:com.mobage.android.shellappsdk.sample.GameWebView.java

private boolean handleExternalDomainUrl(String url) {
    Uri uri = Uri.parse(url);
    String host = uri.getHost();
    if (mDomainWhiteList.containsHost(host)) {
        return false;
    }// ww  w.  j av a 2 s  .  c o m

    // No match - Sending Intent to External Browser
    if ("http".equalsIgnoreCase(uri.getScheme()) || "https".equalsIgnoreCase(uri.getScheme())) {
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (getContext() instanceof Activity) {
            getContext().startActivity(intent);
        }
    }
    return true;
}

From source file:com.tapchatapp.android.app.activity.BuffersActivity.java

@Subscribe
public void onServiceStateChanged(ServiceStateChangedEvent event) {
    final TapchatService service = event.getService();
    if (service.getConnectionState() != TapchatService.STATE_LOADED) {
        return;/*from ww w. j a  v a 2s.c o m*/
    }

    if (mCurrentPage != null) {
        mBus.post(new BufferSelectedEvent(mCurrentPage.getConnectionId(), mCurrentPage.getBufferId(), true));
    }

    Uri data = getIntent().getData();
    final long connectionId = Long.parseLong(data.getHost());
    final long bufferId = Long.parseLong(data.getPath().substring(1));
    final BuffersToDisplay display = BuffersToDisplay.parseString(data.getQueryParameter("display"));

    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);

    mTabsAdapter = (BuffersPagerAdapter) viewPager.getAdapter();
    if (mTabsAdapter == null) {
        mTabsAdapter = new BuffersPagerAdapter(BuffersActivity.this, connectionId, display);
        mTabsAdapter.registerBus();
        viewPager.setAdapter(mTabsAdapter);

        final TitlePageIndicator tabs = (TitlePageIndicator) findViewById(R.id.pager_tabs);
        tabs.setViewPager(viewPager);
        tabs.setOnPageChangeListener(mPageChangeListener);

        if (display == BuffersToDisplay.ConsoleOnly) {
            tabs.setVisibility(View.GONE);
        }

        int selectedItem = mTabsAdapter.getBufferIndex(bufferId);
        if (selectedItem < 0) {
            // FIXME: What to do here? finish() ?
            return;
        }

        viewPager.setCurrentItem(selectedItem);

        // onPageSelected doesn't fire if selectedItem is already
        // selected, causing title to not display.
        mPageChangeListener.onPageSelected(selectedItem);
    }
}

From source file:co.edu.uniajc.vtf.ar.ARViewActivity.java

public boolean listenURL(String uriString) {
    Uri invokedUri = Uri.parse(uriString);
    if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
        final Intent poiDetailIntent = new Intent(ARViewActivity.this, PoiDetailActivity.class);
        String lsId = invokedUri.getQueryParameter("id");
        poiDetailIntent.putExtra("id", Integer.parseInt(lsId));
        ARViewActivity.this.startActivity(poiDetailIntent);
        return true;
    } else {/*from  w w  w  .j a v a  2 s  .  c  o m*/
        return false;
    }
}

From source file:com.notriddle.budget.EnvelopesActivity.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    setContentView(R.layout.activity);/*ww w.j  a va2 s  . c o  m*/
    setupActionBarBackground();
    setupDrawer();

    if (state == null) {
        final Intent i = getIntent();
        final Bundle args = i.getExtras();
        final Uri data = i.getData();
        final String fragmentName = data != null ? data.getHost() : EnvelopesFragment.class.getName();
        try {
            topFragment(Class.forName(fragmentName), FragmentTransaction.TRANSIT_FRAGMENT_FADE, args);
        } catch (Exception e) {
            throw new Error(e);
        }
    } else {
        configureFragment(getFragmentManager().findFragmentById(R.id.content_frame));
    }
}

From source file:com.silverpop.engage.deeplinking.EngageDeepLinkManager.java

private void routeUsingUrl(Uri deeplink) throws JSONException {
    // base case//from  w w w .  j  a  va  2s  .  co m
    if (TextUtils.isEmpty(deeplink.getHost()) && (TextUtils.isEmpty(deeplink.getPath()))) {
        MDLLog.e("MobileDeepLinking", "No Routes Match.");
        routeToDefault(deeplink);
        return;
    }

    if (config.getRoutes() != null) {
        Iterator<String> keys = config.getRoutes().keys();
        while (keys.hasNext()) {
            String route = keys.next();
            JSONObject routeOptions = (JSONObject) config.getRoutes().get(route);
            try {
                Map<String, String> routeParameters = new HashMap<String, String>();
                routeParameters = DeeplinkMatcher.match(route, routeOptions, routeParameters, deeplink);
                if (routeParameters != null) {
                    handleRoute(routeOptions, routeParameters, deeplink);
                    return;
                }
            } catch (JSONException e) {
                MDLLog.e("MobileDeepLinking", "Error parsing JSON!", e);
                break;
            } catch (Exception e) {
                MDLLog.e("MobileDeepLinking", "Error matching and handling route", e);
                break;
            }
        }
    }

    // deeplink trimmer
    routeUsingUrl(trimDeeplink(deeplink));
}

From source file:com.ap.jesus.migsv2.CamActivity.java

@Override
public ArchitectUrlListener getUrlListener() {
    return new ArchitectUrlListener() {

        @Override/*from  www . j a va  2  s.  c  om*/
        public boolean urlWasInvoked(String uriString) {
            Uri invokedUri = Uri.parse(uriString);

            // pressed "More" button on POI-detail panel
            if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
                final Intent poiDetailIntent = new Intent(CamActivity.this, PoiDetailActivity.class);
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_ID,
                        String.valueOf(invokedUri.getQueryParameter("id")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_TITILE,
                        String.valueOf(invokedUri.getQueryParameter("title")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_DESCR,
                        String.valueOf(invokedUri.getQueryParameter("description")));
                CamActivity.this.startActivity(poiDetailIntent);
                return true;
            }

            // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene
            else if ("button".equalsIgnoreCase(invokedUri.getHost())) {
                CamActivity.this.architectView.captureScreen(
                        ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW,
                        new CaptureScreenCallback() {

                            @Override
                            public void onScreenCaptured(final Bitmap screenCapture) {
                                if (ContextCompat.checkSelfPermission(CamActivity.this,
                                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                                    CamActivity.this.screenCapture = screenCapture;
                                    ActivityCompat.requestPermissions(CamActivity.this,
                                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                            WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                                } else {
                                    CamActivity.this.saveScreenCaptureToExternalStorage(screenCapture);
                                }
                            }
                        });
            }
            return true;
        }
    };
}

From source file:ca.rmen.android.poetassistant.main.PagerAdapter.java

PagerAdapter(Context context, FragmentManager fm, Intent intent) {
    super(fm);//  w  w  w  . j  av  a2s .c o m
    Log.v(TAG, "Constructor: intent = " + intent);
    mContext = context;
    Uri initialQuery = intent.getData();
    // Deep link to query in a specific tab
    if (initialQuery != null) {
        Tab tab = Tab.parse(initialQuery.getHost());
        if (tab == Tab.PATTERN) {
            mInitialPatternQuery = initialQuery.getLastPathSegment();
        } else if (tab == Tab.RHYMER) {
            mInitialRhymeQuery = initialQuery.getLastPathSegment();
        } else if (tab == Tab.THESAURUS) {
            mInitialThesaurusQuery = initialQuery.getLastPathSegment();
        } else if (tab == Tab.DICTIONARY) {
            mInitialDictionaryQuery = initialQuery.getLastPathSegment();
        } else if (Constants.DEEP_LINK_QUERY.equals(initialQuery.getHost())) {
            mInitialRhymeQuery = initialQuery.getLastPathSegment();
            mInitialThesaurusQuery = initialQuery.getLastPathSegment();
            mInitialDictionaryQuery = initialQuery.getLastPathSegment();
        }
    }
    // Text shared from another app:
    else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        mInitialPoemText = intent.getStringExtra(Intent.EXTRA_TEXT);
    }
}

From source file:com.spectralinsights.locar.SampleCamActivity.java

@Override
public ArchitectUrlListener getUrlListener() {
    return new ArchitectUrlListener() {

        @Override//from w ww .  j ava2  s.com
        public boolean urlWasInvoked(String uriString) {
            Uri invokedUri = Uri.parse(uriString);

            // pressed "More" button on POI-detail panel
            if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
                final Intent poiDetailIntent = new Intent(SampleCamActivity.this,
                        SamplePoiDetailActivity.class);
                poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_ID,
                        String.valueOf(invokedUri.getQueryParameter("id")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_TITILE,
                        String.valueOf(invokedUri.getQueryParameter("title")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_DESCR,
                        String.valueOf(invokedUri.getQueryParameter("description")));
                SampleCamActivity.this.startActivity(poiDetailIntent);
                return true;
            }

            // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene
            else if ("button".equalsIgnoreCase(invokedUri.getHost())) {
                SampleCamActivity.this.architectView.captureScreen(
                        ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW,
                        new CaptureScreenCallback() {

                            @Override
                            public void onScreenCaptured(final Bitmap screenCapture) {
                                if (ContextCompat.checkSelfPermission(SampleCamActivity.this,
                                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                                    SampleCamActivity.this.screenCapture = screenCapture;
                                    ActivityCompat.requestPermissions(SampleCamActivity.this,
                                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                            WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                                } else {
                                    SampleCamActivity.this.saveScreenCaptureToExternalStorage(screenCapture);
                                }
                            }
                        });
            }
            return true;
        }
    };
}

From source file:io.github.tjg1.nori.fragment.EditAPISettingDialogFragment.java

@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
    // Only show optional authentication inputs for the Danbooru API.
    Uri parsedUri = Uri.parse(uri.getText().toString());
    if (DANBOORU_API_URL.equals(HashUtils.sha512(parsedUri.getHost(), "nori"))) {
        username.setVisibility(View.VISIBLE);
        passphrase.setVisibility(View.VISIBLE);
    } else if (username.getVisibility() != View.GONE) {
        // Empty and hide fields.
        username.setText("");
        username.setVisibility(View.GONE);
        passphrase.setText("");
        passphrase.setVisibility(View.GONE);
    }/*w  w  w .j a  v a2  s. c o m*/
}

From source file:com.piser.apps.AppFive.CamActivity.java

@Override
public ArchitectView.ArchitectUrlListener getUrlListener() {
    return new ArchitectView.ArchitectUrlListener() {

        @Override// w w w . j  av  a 2 s .  co  m
        public boolean urlWasInvoked(String uriString) {
            Uri invokedUri = Uri.parse(uriString);

            // pressed "More" button on POI-detail panel
            if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
                final Intent poiDetailIntent = new Intent(CamActivity.this, PoiDetailActivity.class);
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_ID,
                        String.valueOf(invokedUri.getQueryParameter("id")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_TITILE,
                        String.valueOf(invokedUri.getQueryParameter("title")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_DESCR,
                        String.valueOf(invokedUri.getQueryParameter("description")));
                CamActivity.this.startActivity(poiDetailIntent);
                return true;
            }

            // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene
            else if ("button".equalsIgnoreCase(invokedUri.getHost())) {
                CamActivity.this.architectView.captureScreen(
                        ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW,
                        new ArchitectView.CaptureScreenCallback() {

                            @Override
                            public void onScreenCaptured(final Bitmap screenCapture) {
                                if (ContextCompat.checkSelfPermission(CamActivity.this,
                                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                                    CamActivity.this.screenCapture = screenCapture;
                                    ActivityCompat.requestPermissions(CamActivity.this,
                                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                            WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                                } else {
                                    CamActivity.this.saveScreenCaptureToExternalStorage(screenCapture);
                                }
                            }
                        });
            }
            return true;
        }
    };
}