TedPermission icon indicating copy to clipboard operation
TedPermission copied to clipboard

TedPermission is not functioning properly in activity from widget.

Open Jay-Pyo opened this issue 3 years ago • 0 comments

AndroidManifest.xml

<activity
    android:name=".widget.configure.WidgetConfigureActivity"
    android:launchMode="singleTop"
    android:screenOrientation="portrait" >
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
    </intent-filter>
</activity>

onReceive method of BroadcastReceiver

it receives pending intents from remoteviews in widget

val startActivityIntent =
    Intent(context, WidgetConfigureActivity::class.java).apply {
        addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
        addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
        addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
        putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
    }
context.startActivity(startActivityIntent)

WidgetConfigureActivity

  • check READ_EXTERNAL_STORAGE permission with TedPermission

Problem

When there are background operations (main activities of the application to which the widget belongs).

  1. Before granted
  • When request permission window shows, the activity focus moves on background task (Widget configuration task disappears as soon as the activity focus moves, because the EXCLUDE_FROM_RECENTS and NO_HISTORY flags are present.)
  1. After granted
  • WidgetConfigureActivity is gone after the blink (In guess, it caused by activity focus moving while checking permissions)

Jay-Pyo avatar Jul 31 '21 05:07 Jay-Pyo