Source:
public java.lang.String toUri ( int flags ) { java.lang.StringBuilder uri = new java.lang.StringBuilder ( 128 ) ; if ( ( flags & ( android.content.Intent.URI_ANDROID_APP_SCHEME ) ) != 0 ) { if ( ( mPackage ) == null ) { throw new java.lang.IllegalArgumentException ( ( "Intent must include an explicit package name to build an android-app: " + ( this ) ) ) ; } uri.append ( "android-app://" ) ; uri.append ( mPackage ) ; java.lang.String scheme = null ; if ( ( mData ) != null ) { scheme = mData.getScheme ( ) ; if ( scheme != null ) { uri.append ( '/' ) ; uri.append ( scheme ) ; java.lang.String authority = mData.getEncodedAuthority ( ) ; if ( authority != null ) { uri.append ( '/' ) ; uri.append ( authority ) ; java.lang.String path = mData.getEncodedPath ( ) ; if ( path != null ) { uri.append ( path ) ; } java.lang.String queryParams = mData.getEncodedQuery ( ) ; if ( queryParams != null ) { uri.append ( '?' ) ; uri.append ( queryParams ) ; } java.lang.String fragment = mData.getEncodedFragment ( ) ; if ( fragment != null ) { uri.append ( '#' ) ; uri.append ( fragment ) ; } } } } toUriFragment ( uri , null , ( scheme == null ? android.content.Intent.ACTION_MAIN : android.content.Intent.ACTION_VIEW ) , mPackage , flags ) ; return uri.toString ( ) ; } java.lang.String scheme = null ; if ( ( mData ) != null ) { java.lang.String data = mData.toString ( ) ; if ( ( flags & ( android.content.Intent.URI_INTENT_SCHEME ) ) != 0 ) { final int N = data.length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { char c = data.charAt ( i ) ; if ( ( ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) || ( c == '.' ) ) || ( c == '-' ) ) { continue ; } if ( ( c == ':' ) && ( i > 0 ) ) { scheme = data.substring ( 0 , i ) ; uri.append ( "intent:" ) ; data = data.substring ( ( i + 1 ) ) ; break ; } break ; } } uri.append ( data ) ; } else if ( ( flags & ( android.content.Intent.URI_INTENT_SCHEME ) ) != 0 ) { uri.append ( "intent:" ) ; } toUriFragment ( uri , scheme , android.content.Intent.ACTION_VIEW , null , flags ) ; return uri.toString ( ) ; }

Target:
public java.lang.String toUri ( @ android.content.Intent.UriFlags int flags ) { java.lang.StringBuilder uri = new java.lang.StringBuilder ( 128 ) ; if ( ( flags & ( android.content.Intent.URI_ANDROID_APP_SCHEME ) ) != 0 ) { if ( ( mPackage ) == null ) { throw new java.lang.IllegalArgumentException ( ( "Intent must include an explicit package name to build an android-app: " + ( this ) ) ) ; } uri.append ( "android-app://" ) ; uri.append ( mPackage ) ; java.lang.String scheme = null ; if ( ( mData ) != null ) { scheme = mData.getScheme ( ) ; if ( scheme != null ) { uri.append ( '/' ) ; uri.append ( scheme ) ; java.lang.String authority = mData.getEncodedAuthority ( ) ; if ( authority != null ) { uri.append ( '/' ) ; uri.append ( authority ) ; java.lang.String path = mData.getEncodedPath ( ) ; if ( path != null ) { uri.append ( path ) ; } java.lang.String queryParams = mData.getEncodedQuery ( ) ; if ( queryParams != null ) { uri.append ( '?' ) ; uri.append ( queryParams ) ; } java.lang.String fragment = mData.getEncodedFragment ( ) ; if ( fragment != null ) { uri.append ( '#' ) ; uri.append ( fragment ) ; } } } } toUriFragment ( uri , null , ( scheme == null ? android.content.Intent.ACTION_MAIN : android.content.Intent.ACTION_VIEW ) , mPackage , flags ) ; return uri.toString ( ) ; } java.lang.String scheme = null ; if ( ( mData ) != null ) { java.lang.String data = mData.toString ( ) ; if ( ( flags & ( android.content.Intent.URI_INTENT_SCHEME ) ) != 0 ) { final int N = data.length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { char c = data.charAt ( i ) ; if ( ( ( ( ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) ) || ( ( c >= '0' ) && ( c <= '9' ) ) ) || ( c == '.' ) ) || ( c == '-' ) ) || ( c == '+' ) ) { continue ; } if ( ( c == ':' ) && ( i > 0 ) ) { scheme = data.substring ( 0 , i ) ; uri.append ( "intent:" ) ; data = data.substring ( ( i + 1 ) ) ; break ; } break ; } } uri.append ( data ) ; } else if ( ( flags & ( android.content.Intent.URI_INTENT_SCHEME ) ) != 0 ) { uri.append ( "intent:" ) ; } toUriFragment ( uri , scheme , android.content.Intent.ACTION_VIEW , null , flags ) ; return uri.toString ( ) ; }