I am working on an App which uses Android's Picture-in-Picture Mode.
The MainActivity has a button which launches some other activity(simply fire intent to another Activity). The issue occurs when i enter the PIP Mode and expands the MainActivity, Now when i click the Button, The new Activity takes around 7-8 seconds to become visible. Also if the pattern is repeated, The intent of the activity is completely ignored and SampleActivity never launches.
Everything is working fine below Android-12. Happening on Pixel devices(as 12 is available only on pixels for now.)
Here are sample code snippets(Sample project code with same problem).
Manifest file:
<activity
android:name=".MainActivity"
android:exported="true"
android:taskAffinity=".MainActivity"
android:configChanges=
"screenSize|smallestScreenSize|screenLayout|orientation"
android:resizeableActivity="true"
android:screenOrientation="portrait"
android:supportsPictureInPicture="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SampleActivity" />
PIP Mode:
enterPictureInPictureMode(
PictureInPictureParams.Builder().setActions()
.setAspectRatio(
Rational(
140,
190
)
)
.build()
)
Button Click Intent
findViewById<Button>(R.id.btnClickMe).setOnClickListener {
(it as? Button)?.text = "Clicked"
val intent = Intent(this@MainActivity, SampleActivity::class.java)
startActivity(intent)
}
Tried playing with Manifest flags/configs but no luck. Pls provide necessary suggestions.