- I have been doing InAppBrowser(Webview to load an url) in Nativescript. From nativescript, I want to use InAppbrowser native android webview code for some reason.
- So I got one sample link to look out:
https://www.codeday.top/2017/10/23/52017.html
- With the help of reference I tried to pass activity context from nativescript file to typescript.
Error : But I'm getting cannot convert object to context error in Command prompt.
- Below I have posted the code what I have been tried so far:
app.component.ts:
var activity:any = android.app.Activity;
export class AppComponent {
onTap(args: EventData) {
org.example.MyToast.showToast(activity); --> Here I'm passing object.So it doesn't take activity context reference. That's why I'm getting error.
}
}
MyToast.java:
public class MyToast {
public static void showToast(Context context) {
final Dialog openDialog = new Dialog(context);
}
}
I don't know how to pass activity context reference in nativescript to typescript file. Could anyone help me out.
var activity:any = android.app.Activity;use current class contextvar activity:any =this;android.app.Activity.extend("your class with packge name")like for ex= "com.AppComponent".