Example usage for android.net Uri getScheme

List of usage examples for android.net Uri getScheme

Introduction

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

Prototype

@Nullable
public abstract String getScheme();

Source Link

Document

Gets the scheme of this URI.

Usage

From source file:com.zfb.house.emchat.ChatActivity.java

/**
 * ??// ww w  .  ja va2s  .co  m
 *
 * @param uri
 */
private void sendFile(Uri uri) {
    String filePath = null;
    if ("content".equalsIgnoreCase(uri.getScheme())) {
        String[] projection = { "_data" };
        Cursor cursor = null;

        try {
            cursor = getContentResolver().query(uri, projection, null, null, null);
            int column_index = cursor.getColumnIndexOrThrow("_data");
            if (cursor.moveToFirst()) {
                filePath = cursor.getString(column_index);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if ("file".equalsIgnoreCase(uri.getScheme())) {
        filePath = uri.getPath();
    }
    File file = new File(filePath);
    if (file == null || !file.exists()) {
        String st7 = getResources().getString(R.string.File_does_not_exist);
        Toast.makeText(getApplicationContext(), st7, Toast.LENGTH_SHORT).show();
        return;
    }
    if (file.length() > 10 * 1024 * 1024) {
        String st6 = getResources().getString(R.string.The_file_is_not_greater_than_10_m);
        Toast.makeText(getApplicationContext(), st6, Toast.LENGTH_SHORT).show();
        return;
    }

    // ?
    EMMessage message = EMMessage.createSendMessage(EMMessage.Type.FILE);
    // ?chattype,??
    if (chatType == CHATTYPE_GROUP) {
        message.setChatType(ChatType.GroupChat);
    } else if (chatType == CHATTYPE_CHATROOM) {
        message.setChatType(ChatType.ChatRoom);
    }

    message.setReceipt(toChatUsername);
    // add message body
    NormalFileMessageBody body = new NormalFileMessageBody(new File(filePath));
    message.addBody(body);
    if (isRobot) {
        message.setAttribute("em_robot_message", true);
    }
    addAttribute2Msg(message);
    listView.setAdapter(adapter);
    adapter.refreshSelectLast();
    setResult(RESULT_OK);
}

From source file:com.tct.mail.browse.ConversationCursor.java

/**
 * Regenerate the original Uri from a forwarding (ConversationProvider) Uri
 * NOTE: See note above for uriToCachingUri
 * @param uri the forwarding Uri/*www. ja v  a 2 s  . c  o m*/
 * @return the original Uri
 */
public static Uri uriFromCachingUri(Uri uri) { //TS: zheng.zou 2015-07-17 EMAIL BUGFIX_-943618 MOD
    String authority = uri.getAuthority();
    // Don't modify uri's that aren't ours
    if (!authority.equals(ConversationProvider.AUTHORITY)) {
        return uri;
    }
    List<String> path = uri.getPathSegments();
    Uri.Builder builder = new Uri.Builder().scheme(uri.getScheme()).authority(path.get(0));
    for (int i = 1; i < path.size(); i++) {
        builder.appendPath(path.get(i));
    }
    return builder.build();
}

From source file:com.kncwallet.wallet.ui.SendCoinsFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.send_coins_fragment, container, false);
    contactsListView = (ListView) view.findViewById(R.id.send_coins_contacts_list);

    viewBalanceBtc = (CurrencyTextView) view.findViewById(R.id.wallet_balance_btc);

    txText = (EditText) view.findViewById(R.id.send_coins_text);

    viewBalanceLocal = (CurrencyTextView) view.findViewById(R.id.wallet_balance_local);

    viewBalanceLocal.setPrecision(Constants.LOCAL_PRECISION, 0);
    viewBalanceLocal.setStrikeThru(Constants.TEST);

    viewBalanceBtc.setOnClickListener(new OnClickListener() {
        @Override/* ww  w .j ava 2s .  c  o  m*/
        public void onClick(final View v) {
            SendCoinsFragment.this.switchBalance();
        }
    });

    viewBalanceLocal.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            SendCoinsFragment.this.switchBalance();
        }
    });

    receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address);
    receivingAddressView.setAdapter(new AutoCompleteAddressAdapter(activity, null));
    receivingAddressView.setOnFocusChangeListener(receivingAddressListener);
    receivingAddressView.addTextChangedListener(receivingAddressListener);

    receivingStaticView = view.findViewById(R.id.send_coins_receiving_static);
    receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address);
    receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label);

    receivingStaticView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {

            if (hasFocus) {
                startReceivingAddressActionMode();
            } else {
                clearActionMode();
            }
        }
    });

    btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc);
    btcAmountView.setCurrencySymbol(DenominationUtil.getCurrencyCode(btcShift));
    btcAmountView.setInputPrecision(DenominationUtil.getMaxPrecision(btcShift));
    btcAmountView.setHintPrecision(btcPrecision);
    btcAmountView.setShift(btcShift);

    final CurrencyAmountView localAmountView = (CurrencyAmountView) view
            .findViewById(R.id.send_coins_amount_local);
    localAmountView.setInputPrecision(Constants.LOCAL_PRECISION);
    localAmountView.setHintPrecision(Constants.LOCAL_PRECISION);
    amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView);

    bluetoothEnableView = (CheckBox) view.findViewById(R.id.send_coins_bluetooth_enable);
    bluetoothEnableView.setChecked(bluetoothAdapter != null && bluetoothAdapter.isEnabled());
    bluetoothEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            if (isChecked && !bluetoothAdapter.isEnabled()) {
                // try to enable bluetooth
                startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE),
                        REQUEST_CODE_ENABLE_BLUETOOTH);
            }
        }
    });

    bluetoothMessageView = (TextView) view.findViewById(R.id.send_coins_bluetooth_message);

    sentTransactionView = (ListView) view.findViewById(R.id.send_coins_sent_transaction);
    sentTransactionListAdapter = new TransactionsListAdapter(activity, wallet, application.maxConnectedPeers(),
            false);
    sentTransactionView.setAdapter(sentTransactionListAdapter);

    viewGo = (Button) view.findViewById(R.id.send_coins_go);
    viewGo.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            validateReceivingAddress(true);
            validateAmounts(true);

            if (everythingValid())
                handleGo();
        }
    });

    if (savedInstanceState != null) {
        restoreInstanceState(savedInstanceState);
    } else {
        final Intent intent = activity.getIntent();
        final String action = intent.getAction();
        final Uri intentUri = intent.getData();
        final String scheme = intentUri != null ? intentUri.getScheme() : null;

        if ((Intent.ACTION_VIEW.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action))
                && intentUri != null && "bitcoin".equals(scheme))
            initStateFromBitcoinUri(intentUri);
        else if (intent.hasExtra(SendCoinsFragment.INTENT_EXTRA_ADDRESS))
            initStateFromIntentExtras(intent.getExtras());
    }

    TextView header = ((TextView) view.findViewById(R.id.header_text));

    header.setText(R.string.send_heading);

    contactListAdapter = new SimpleCursorAdapter(activity, R.layout.address_book_row_small, null,
            new String[] { AddressBookProvider.KEY_ADDRESS, AddressBookProvider.KEY_LABEL,
                    AddressBookProvider.KEY_ADDRESS, AddressBookProvider.KEY_ADDRESS },
            new int[] { R.id.address_book_contact_image, R.id.address_book_row_label,
                    R.id.address_book_row_address, R.id.address_book_row_source_image });

    contactListAdapter.setViewBinder(new ViewBinder() {
        @Override
        public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) {
            if (view.getId() == R.id.address_book_contact_image) {
                //...
                SmartImageView img = (SmartImageView) view;
                //img.setImageBitmap(bm);
                String address = cursor.getString(columnIndex);
                Bitmap contactImage = AddressBookProvider.bitmapForAddress(SendCoinsFragment.this.getActivity(),
                        address);
                if (contactImage != null) {
                    img.setImageBitmap(contactImage);
                } else {

                    String imageUrl = ContactImage.getImageUrl(activity,
                            AddressBookProvider.resolveRowId(activity, address));
                    if (imageUrl != null) {
                        img.setImageUrl(imageUrl, R.drawable.contact_placeholder);
                    } else {
                        img.setImageResource(R.drawable.contact_placeholder);
                    }

                }

                return true; //true because the data was bound to the view
            } else if (view.getId() == R.id.address_book_row_source_image) {
                ((ImageView) view).setImageResource(cachedSourceImageResource(cursor.getString(columnIndex)));
                return true;
            }

            //Constants.ADDRESS_FORMAT_LINE_SIZE));

            return false;
        }
    });

    boolean smallScreen = getResources().getBoolean(R.bool.values_small);

    if (!smallScreen) {
        ListView list = (ListView) contactsListView;
        Drawable divider = getResources().getDrawable(R.drawable.transaction_list_divider);
        list.setDivider(divider);
        list.setDividerHeight(1);
        list.setAdapter(contactListAdapter);

        list.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                //to save a lookup
                TextView addr = (TextView) view.findViewById(R.id.address_book_row_address);
                TextView label = (TextView) view.findViewById(R.id.address_book_row_label);

                if (setSendAddress(addr.getText().toString(), label.getText().toString())) {
                    startReceivingAddressActionMode();
                } else {
                    informInvalidAddress(addr.getText().toString(), label.getText().toString());
                }

            }
        });
    } else {
        contactsListView.setVisibility(View.GONE);
    }

    return view;
}

From source file:com.android.server.telecom.testapps.TestConnectionService.java

@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerAccount,
        final ConnectionRequest originalRequest) {

    final Uri handle = originalRequest.getAddress();
    String number = originalRequest.getAddress().getSchemeSpecificPart();
    log("call, number: " + number);

    // Crash on 555-DEAD to test call service crashing.
    if ("5550340".equals(number)) {
        throw new RuntimeException("Goodbye, cruel world.");
    }//from   w  ww.  j  a v a  2 s.co  m

    Bundle extras = originalRequest.getExtras();
    String gatewayPackage = extras.getString(TelecomManager.GATEWAY_PROVIDER_PACKAGE);
    Uri originalHandle = extras.getParcelable(TelecomManager.GATEWAY_ORIGINAL_ADDRESS);

    log("gateway package [" + gatewayPackage + "], original handle [" + originalHandle + "]");

    final TestConnection connection = new TestConnection(false /* isIncoming */);
    setAddress(connection, handle);

    // If the number starts with 555, then we handle it ourselves. If not, then we
    // use a remote connection service.
    // TODO: Have a special phone number to test the account-picker dialog flow.
    if (number != null && number.startsWith("555")) {
        // Normally we would use the original request as is, but for testing purposes, we are
        // adding ".." to the end of the number to follow its path more easily through the logs.
        final ConnectionRequest request = new ConnectionRequest(originalRequest.getAccountHandle(),
                Uri.fromParts(handle.getScheme(), handle.getSchemeSpecificPart() + "..", ""),
                originalRequest.getExtras(), originalRequest.getVideoState());
        connection.setVideoState(originalRequest.getVideoState());
        /// M: only VideoCall addVideoProvider @{
        if (originalRequest.getVideoState() == VideoProfile.STATE_BIDIRECTIONAL) {
            addVideoProvider(connection);
        }
        /// @}

        addCall(connection);
        connection.startOutgoing();

        for (Connection c : getAllConnections()) {
            c.setOnHold();
        }
    } else {
        log("Not a test number");
    }
    return connection;
}

From source file:com.tct.mail.providers.Attachment.java

public static String getPath(final Context context, final Uri uri) {
    // DocumentProvider
    if (DocumentsContract.isDocumentUri(context, uri)) {
        // ExternalStorageProvider
        if (isExternalStorageDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            if ("primary".equalsIgnoreCase(type)) {
                return Environment.getExternalStorageDirectory() + "/" + split[1];
            }/*from   w  w w . j av a 2s  . co m*/

            // TODO handle non-primary volumes
        }
        // DownloadsProvider
        else if (isDownloadsDocument(uri)) {

            final String id = DocumentsContract.getDocumentId(uri);
            final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
                    Long.valueOf(id));

            return getDataColumn(context, contentUri, null, null);
        }
        // MediaProvider
        else if (isMediaDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

            final String selection = "_id=?";
            final String[] selectionArgs = new String[] { split[1] };

            return getDataColumn(context, contentUri, selection, selectionArgs);
        }
    }
    // MediaStore (and general)
    else if ("content".equalsIgnoreCase(uri.getScheme())) {

        // Return the remote address
        if (isGooglePhotosUri(uri))
            return uri.getLastPathSegment();

        return getDataColumn(context, uri, null, null);
    }
    // File
    else if ("file".equalsIgnoreCase(uri.getScheme())) {
        return uri.getPath();
    }

    return null;
}

From source file:com.fullteem.yueba.app.ui.ChatActivity.java

/**
 * ??//from ww  w . ja  v a2s.  c o  m
 * 
 * @param uri
 */
private void sendFile(Uri uri) {
    String filePath = null;
    if ("content".equalsIgnoreCase(uri.getScheme())) {
        String[] projection = { "_data" };
        Cursor cursor = null;

        try {
            cursor = getContentResolver().query(uri, projection, null, null, null);
            int column_index = cursor.getColumnIndexOrThrow("_data");
            if (cursor.moveToFirst()) {
                filePath = cursor.getString(column_index);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if ("file".equalsIgnoreCase(uri.getScheme())) {
        filePath = uri.getPath();
    }
    File file = new File(filePath);
    if (file == null || !file.exists()) {
        Toast.makeText(getApplicationContext(), "?", 0).show();
        return;
    }
    if (file.length() > 10 * 1024 * 1024) {
        Toast.makeText(getApplicationContext(), "?10M", 0).show();
        return;
    }

    // ?
    EMMessage message = EMMessage.createSendMessage(EMMessage.Type.FILE);
    // ?chattype,??
    if (chatType == CHATTYPE_GROUP)
        message.setChatType(ChatType.GroupChat);

    message.setReceipt(toChatUsername);
    // add message body
    NormalFileMessageBody body = new NormalFileMessageBody(new File(filePath));
    message.addBody(body);
    conversation.addMessage(message);
    listView.setAdapter(adapter);
    adapter.refresh();
    listView.setSelection(listView.getCount() - 1);
    setResult(RESULT_OK);
}

From source file:jackpal.androidterm.RemoteInterface.java

protected void handleIntent() {
    TermService service = getTermService();
    if (service == null) {
        finish();/*from  ww  w. j a va  2  s .  co  m*/
        return;
    }

    Intent myIntent = getIntent();
    String action = myIntent.getAction();

    if (action == null) {
        finish();
        return;
    }
    ClipData clipData = myIntent.getClipData();
    if ((AndroidCompat.SDK >= 19 && action.equals(Intent.ACTION_SEND) && myIntent.hasExtra(Intent.EXTRA_STREAM))
            || (action.equals(Intent.ACTION_SEND) && clipData != null)
            || (action.equals("android.intent.action.VIEW")) || (action.equals("android.intent.action.EDIT"))
            || (action.equals("android.intent.action.PICK"))
            || (action.equals("com.googlecode.android_scripting.action.EDIT_SCRIPT"))) {
        String url = null;
        Uri uri = null;
        if (clipData != null) {
            uri = clipData.getItemAt(0).getUri();
            if (uri == null) {
                openText(clipData.getItemAt(0).getText());
                finish();
                return;
            }
        } else if (AndroidCompat.SDK >= 19 && action.equals(Intent.ACTION_SEND)
                && myIntent.hasExtra(Intent.EXTRA_STREAM)) {
            Object extraStream = myIntent.getExtras().get(Intent.EXTRA_STREAM);
            if (extraStream instanceof Uri) {
                uri = (Uri) extraStream;
            }
        } else {
            uri = myIntent.getData();
        }
        String intentCommand = "sh ";
        if (mSettings.getInitialCommand().matches("(.|\n)*(^|\n)-vim\\.app(.|\n)*")) {
            intentCommand = ":e ";
        }
        boolean flavorVim = intentCommand.matches("^:.*");
        if (uri != null && uri.toString().matches("^file:///.*") && flavorVim) {
            String path = uri.getPath();
            if (new File(path).canRead()) {
                path = path.replaceAll(Term.SHELL_ESCAPE, "\\\\$1");
                String command = "\u001b" + intentCommand + path;
                // Find the target window
                mReplace = true;
                mHandle = switchToWindow(mHandle, command);
                mReplace = false;
            }
            finish();
        } else if (AndroidCompat.SDK >= 19 && uri != null && uri.getScheme() != null
                && uri.getScheme().equals("content") && flavorVim) {
            Context context = this;
            String command = null;
            String path = Term.getPath(context, uri);
            if (path != null) {
                path = path.replaceAll(Term.SHELL_ESCAPE, "\\\\$1");
                command = "\u001b" + intentCommand + path;
            } else if (getContentResolver() != null) {
                try {
                    Cursor cursor = getContentResolver().query(uri, null, null, null, null, null);
                    path = Term.handleOpenDocument(uri, cursor);
                } catch (Exception e) {
                    alert(e.toString() + "\n" + this.getString(R.string.storage_read_error));
                    finish();
                }
                if (path == null) {
                    alert(this.getString(R.string.storage_read_error));
                    finish();
                } else {
                    File dir = Term.getScratchCacheDir(this);
                    SyncFileObserver sfo = new SyncFileObserver(path);
                    sfo.setConTentResolver(this.getContentResolver());
                    path = dir.toString() + path;
                    String fname = new File(path).getName();
                    if (path.equals("") || !sfo.putUriAndLoad(uri, path)) {
                        alert(fname + "\n" + this.getString(R.string.storage_read_error));
                        finish();
                    }
                    path = path.replaceAll(Term.SHELL_ESCAPE, "\\\\$1");
                    command = "\u001b" + intentCommand + path;
                }
            }
            // Find the target window
            mReplace = true;
            mHandle = switchToWindow(mHandle, command);
            mReplace = false;
            finish();
        } else if (action.equals("com.googlecode.android_scripting.action.EDIT_SCRIPT")) {
            url = myIntent.getExtras().getString("com.googlecode.android_scripting.extra.SCRIPT_PATH");
        } else if (myIntent.getScheme() != null && myIntent.getScheme() != null
                && myIntent.getScheme().equals("file")) {
            if (myIntent.getData() != null)
                url = myIntent.getData().getPath();
        }
        if (url != null) {
            String command = "sh ";
            if (mSettings.getInitialCommand().matches("(.|\n)*(^|\n)-vim\\.app(.|\n)*")) {
                command = ":e ";
            }
            if (command.matches("^:.*")) {
                url = url.replaceAll(Term.SHELL_ESCAPE, "\\\\$1");
                command = "\u001b" + command + url;
                // Find the target window
                mReplace = true;
                mHandle = switchToWindow(mHandle, command);
                mReplace = false;
            } else if ((mHandle != null) && (url.equals(mFname))) {
                // Target the request at an existing window if open
                command = command + url;
                mHandle = switchToWindow(mHandle, command);
            } else {
                // Open a new window
                command = command + url;
                mHandle = openNewWindow(command);
            }
            mFname = url;

            Intent result = new Intent();
            result.putExtra(EXTRA_WINDOW_HANDLE, mHandle);
            setResult(RESULT_OK, result);
        }
    } else if (action.equals(Intent.ACTION_SEND) && myIntent.hasExtra(Intent.EXTRA_TEXT)) {
        openText(myIntent.getExtras().getCharSequence(Intent.EXTRA_TEXT));
    } else {
    }

    finish();
}

From source file:com.taobao.weex.WXSDKInstance.java

private void renderByUrlInternal(String pageName, final String url, Map<String, Object> options,
        final String jsonInitData, final WXRenderStrategy flag) {

    ensureRenderArchor();//from  ww  w. j  a v  a  2s . com
    pageName = wrapPageName(pageName, url);
    mBundleUrl = url;
    if (WXSDKManager.getInstance().getValidateProcessor() != null) {
        mNeedValidate = WXSDKManager.getInstance().getValidateProcessor().needValidate(mBundleUrl);
    }

    Map<String, Object> renderOptions = options;
    if (renderOptions == null) {
        renderOptions = new HashMap<>();
    }
    if (!renderOptions.containsKey(BUNDLE_URL)) {
        renderOptions.put(BUNDLE_URL, url);
    }

    mApmForInstance.doInit();

    Uri uri = Uri.parse(url);
    if (uri != null && TextUtils.equals(uri.getScheme(), "file")) {
        mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START);
        String template = WXFileUtils.loadFileOrAsset(assembleFilePath(uri), mContext);
        mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_END);
        render(pageName, template, renderOptions, jsonInitData, flag);
        return;
    }

    IWXHttpAdapter adapter = WXSDKManager.getInstance().getIWXHttpAdapter();

    WXRequest wxRequest = new WXRequest();
    wxRequest.url = rewriteUri(Uri.parse(url), URIAdapter.BUNDLE).toString();
    if (wxRequest != null && !TextUtils.isEmpty(wxRequest.url)) {
        requestUrl = wxRequest.url;
    } else {
        requestUrl = pageName;
    }

    if (wxRequest.paramMap == null) {
        wxRequest.paramMap = new HashMap<String, String>();
    }
    wxRequest.instanceId = getInstanceId();
    wxRequest.paramMap.put(KEY_USER_AGENT, WXHttpUtil.assembleUserAgent(mContext, WXEnvironment.getConfig()));
    WXHttpListener httpListener = new WXHttpListener(pageName, renderOptions, jsonInitData, flag,
            System.currentTimeMillis());
    httpListener.setSDKInstance(this);
    adapter.sendRequest(wxRequest, (IWXHttpAdapter.OnHttpListener) httpListener);
}

From source file:com.aimfire.gallery.GalleryActivity.java

/**
 * this activity (GalleryActivity) can receive intent from: 
 * 1. ThumbsFragment - when a thumbnail is selected
 * 2. PhotoProcessor - when a photo is finished processing
 * 3. MovieProcessor - when a movie is finished processing
 * 4. user click a .cvr file from file browser
 * 5. user click link (of amifire-vr scheme) in browser
 * 6. user click link (with our domain name) in mail or other programs (other than browser)
 * //ww  w  . j  a v  a  2  s.co m
 * in the first three cases, the intent we get will have extras EXTRA_PATH and EXTRA_MSG.
 * in the fourth case, we will have intent with getData with path to the .cvr file (or occasionally jpg file).
 * in the last two cases, we will have a link that we need to parse.
 */
private void parseIntent(Intent intent) {
    /*
     * set mIsMyMedia according to intent. we may or may not have EXTRA_MSG
     * passed in. in case we don't have it passed in we will set it to false
     * here by default. it may get overriden after we parsed the intent.
     */
    mIsMyMedia = intent.getBooleanExtra(MainConsts.EXTRA_MSG, false);

    String filePath = null;

    Uri uri = intent.getData();

    if (uri != null) {
        if (uri.getScheme().equalsIgnoreCase("file")) {
            filePath = handleLocalOpen(uri);
        } else if (uri.getScheme().equalsIgnoreCase("https") || uri.getScheme().equalsIgnoreCase("http")
                || uri.getScheme().equalsIgnoreCase("aimfire-vr")) {
            filePath = handleDownload(uri);
        }
    } else {
        filePath = intent.getStringExtra(MainConsts.EXTRA_PATH);
    }

    if (filePath == null) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "parseIntent: filePath is null");
        return;
    }

    /*
     * update view pager - if file is already in the view pager, this will 
     * updates its view only. if it is not, this will refresh the entire
     * view pager to add it.
     */
    updateViewPager(filePath, -1, -1);
}

From source file:com.taobao.weex.WXSDKInstance.java

private String wrapPageName(String pageName, String url) {
    if (TextUtils.equals(pageName, WXPerformance.DEFAULT)) {
        pageName = url;//from w w w .j  a v  a2  s .co  m
        WXExceptionUtils.degradeUrl = pageName;
        try {
            Uri uri = Uri.parse(url);
            if (uri != null) {
                Uri.Builder builder = new Uri.Builder();
                builder.scheme(uri.getScheme());
                builder.authority(uri.getAuthority());
                builder.path(uri.getPath());
                pageName = builder.toString();
            }
        } catch (Exception e) {
        }
    }
    return pageName;
}