utils.uts 479 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import Intent from 'android.content.Intent';
import Uri from 'android.net.Uri';

export function openSchema(url : string) : Promise<boolean> {
  return new Promise<boolean>((resolve, reject) => {
    try {
      const context = UTSAndroid.getUniActivity()!;
      const uri = Uri.parse(url)
      const intent = new Intent(Intent.ACTION_VIEW, uri)
      intent.setData(uri);
      context.startActivity(intent);
      resolve(true)
    } catch (e) {
      reject(e)
    }
  })
}