navigator add openUrl
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package pub.doric.plugin;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.github.pengfeizhou.jscore.ArchiveException;
|
||||
import com.github.pengfeizhou.jscore.JSDecoder;
|
||||
import com.github.pengfeizhou.jscore.JSObject;
|
||||
@@ -84,4 +87,17 @@ public class NavigatorPlugin extends DoricJavaPlugin {
|
||||
promise.reject(new JavaValue("Navigator not implemented"));
|
||||
}
|
||||
}
|
||||
|
||||
@DoricMethod(thread = ThreadMode.UI)
|
||||
public void openUrl(String url, DoricPromise promise) {
|
||||
try {
|
||||
Uri uri = Uri.parse(url);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(uri);
|
||||
getDoricContext().getContext().startActivity(intent);
|
||||
promise.resolve();
|
||||
} catch (Exception e) {
|
||||
promise.reject(new JavaValue(e.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user