invite app with instagram code example
Example: invite app with instagram
fun shareWithInstagram(context: Context) {
try {
//val file: Uri = Uri.parse("android.resource://your.pacakage/" + R.mipmap.ic_logo)
val shareIntent = Intent(Intent.ACTION_SEND)
//shareIntent.type = "image/*"
shareIntent.type = "text/plain"
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
//shareIntent.putExtra(Intent.EXTRA_STREAM, file)
//invite content is like combination of url and decreption
shareIntent.putExtra(Intent.EXTRA_TEXT, INVITE_CONTENT)
shareIntent.setPackage("com.instagram.android")
context.startActivity(shareIntent)
}
catch (e: Exception) {
//app not installed
context.toast("Instagram App is not installed")
//go with share sheet
shareWithOtherApps(context)
}
}