index.uts 561 字节
Newer Older
D
DCloud_LXH 已提交
1 2 3 4 5 6 7 8 9
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)
VK1688's avatar
VK1688 已提交
10
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
D
DCloud_LXH 已提交
11 12 13 14 15 16
    intent.setData(uri)
    context.startActivity(intent)
  } else {
    console.error('url param ERROR:', JSON.stringify(url))
  }
}