Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TedPermission is not functioning properly in activity from widget. #124

Open
Jay-Pyo opened this issue Jul 31, 2021 · 0 comments
Open

TedPermission is not functioning properly in activity from widget. #124

Jay-Pyo opened this issue Jul 31, 2021 · 0 comments

Comments

@Jay-Pyo
Copy link

Jay-Pyo commented Jul 31, 2021

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant