更新时间:2023-10-03 09:45:40
这可以使用模块tns-core-modules/application
来实现,该模块将使startActivity
可用.下面提供了一个使用TypeScript的示例:
This can be achieved using the module tns-core-modules/application
, which will make startActivity
available. An example using TypeScript is provided below:
import * as appM from 'tns-core-modules/application';
const intent = new android.content.Intent(android.provider.Settings.ACTION_SETTINGS);
const activity = appM.android.foregroundActivity || appM.android.startActivity;
activity.startActivityForResult(intent, 0);
不幸的是,foregroundActivity
和startActivity
不包含TypeScript类型,这使得寻找解决方案变得非常困难.
非常感谢 user10655801 包含解决方案的测试仓库.
Unfortunately, TypeScript types are not included for foregroundActivity
and startActivity
, which made finding a solution to this extremely hard.
A big thanks to user10655801 for his test repo containing the solution.