Reputation: 185
Is it possible to call the following code within a cordova project?
Intent intent = new Intent("android.net.vpn.SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
I tried to use WebIntent (link), but it does not support the set of a flag, furthermore I dont know how I have to set the options.
Upvotes: 0
Views: 772
Reputation: 77904
No
Cordova uses one Activity only (Web View) so you cannot open new Activity.
But Ionic (Angular) supports states and you can switch views inside web view
What you try to do is to open Settings that is not part of your application.
So you can call Java method from Cordova and call your code
Java
private boolean openWifiSettings(final CallbackContext callbackContext) {
final CordovaPlugin plugin = this;
this.cordova.getThreadPool().execute(new Runnable() {
public void run() {
cordova.startActivityForResult(plugin, new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS), 0);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
}
});
return true;
}
and in javascript:
YourPlugin.prototype.openWifiSettings = function (successCallback, errorCallback) {
cordova.exec(successCallback, errorCallback, "MoodoPlugin", "openWifiSettings", []); //
};
Upvotes: 3