I need the following logic: when I click a button, google search string opens up, like this
I have the following in MainActivity:
val mainBtn = findViewById<Button>(R.id.main_btn)
mainBtn.setOnClickListener {
val intent = Intent(Intent.ACTION_WEB_SEARCH)
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent)
} else {
Toast.makeText(this, "Sorry, no such app", Toast.LENGTH_SHORT).show()
}
}
and the following in Manifest file:
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.WEB_SEARCH"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
Thank you in advance for any help