Home > Mobile >  How to open an application in my application with click bottom (android Studio )
How to open an application in my application with click bottom (android Studio )

Time:12-03

I would like to open an application in my application with ( jetpack compose, kotlin or java ) Do you think it's doable?

Currently, it opens it for me when leaving my application with this code

@Composable
fun HomeView(navController: NavController){

   val context = LocalContext.current
   intent.setPackage("com.whatsapp")
   intent.setType("message/rfc822")
   Button(onClick = {
     context.startActivity(Intent.createChooser(intent,"choisir un app"))
    }){
          Text(text="open whatsapp like an iframe ")
      }
}

an example of the result I want to have. whatsapp is launched in my application with my appBar

This post stackoverflow from 6 years ago said it was not possible. But with the arrival of jetpack compose and recent versions of Android. I also wonder if that has changed.

CodePudding user response:

It is possible to open an external application within your application using jetpack compose and kotlin or java. You can use the following code to launch the external application:

@Composable
fun HomeView(navController: NavController){

val context = LocalContext.current
intent.setPackage("com.whatsapp")
intent.setType("message/rfc822")
Button(onClick = {
context.startActivity(Intent.createChooser(intent,"choisir un app"))
}){
Text(text="open whatsapp like an iframe ")
}
}

However, it may not be possible to display the external application within your application like an iframe, as it would require integration with the external application's code. It is best to check with the developers of the external application to see if this is possible.

  • Related