import Intent from 'android.content.Intent'
import Uri from 'android.net.Uri'
import { OpenSchema } from '../interface.uts'

export const openSchema: OpenSchema = function (url: string) {
  if (typeof url === 'string' && url.length > 0) {
    const context = UTSAndroid.getUniActivity()!
    const uri = Uri.parse(url)
    const intent = new Intent(Intent.ACTION_VIEW, uri)
    intent.setData(uri)
    context.startActivity(intent)
  } else {
    console.error('url param ERROR：', JSON.stringify(url))
  }
}
