最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Flutter Android Homescreen widget implementation - application may be doing too much work on its main thread - Stack Overflow

programmeradmin1浏览0评论

I am implementing Android home screen widgets for the first time and want to open a homescreen widget config screen wehn a user goes to add a widget. WHich I call from here:

class WidgetConfigActivity : FlutterActivity() {

    private var appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d("WidgetConfigActivity", "onCreate invoked")
        val extras = intent.extras
        if (extras != null) {
            appWidgetId = extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID
            )
        }
        Log.d("WidgetConfigActivity", "AppWidgetId: $appWidgetId") // Add this line

        if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
            finish()
        }
    }

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        MethodChannel(
            flutterEngine.dartExecutor.binaryMessenger,
            "widget_config_channel"
        ).setMethodCallHandler { call, result ->
            when (call.method) {
                "finishConfig" -> {
                    val returnIntent = Intent()
                    returnIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
                    setResult(RESULT_OK, returnIntent)
                    finish()
                    result.success(true)
                }
                "getAppWidgetId" -> {
                    // Simply return the appWidgetId stored in this Activity
                    result.success(appWidgetId)
                }
                else -> {
                    result.notImplemented()
                }
            }
        }
    }

    override fun getInitialRoute(): String? {
    return "/widgetConfig"
}
}

I have the route defined in my apps main file here:

 Widget build(BuildContext context) {
    // Provider.of<RevenueCatProvider>(context, listen: false)
    //     .initPlatformPurchaseStateRevenueCat();
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      routes: {
        '/addLocation': (context) => const AddLocation(),
        '/locationDetailsView': (context) => const LocationDetailsView(),
        '/userSettings': (context) => const UserSettings(),
        '/manageLocations': (context) => const ManageLocations(),
        '/myApp': (context) => MyApp(isFirstRun),
        '/manageUnits': (context) => const ManageUnits(),
        '/homePageV2': (context) => const HomePageV2(),
        '/locationDetailsViewV2': (context) => const LocationDetailsViewV2(),
        '/shareForecast': (context) => const ShareForecast(),
        '/widgetConfig': (context) => WidgetConfigScreen(),
      },

When I try to test this in production. Tried both emmulator and real phone I get a dark screen. If I hit hot reload then it resumes form the black screen and actually goes to my config screen. I see this error in my debugg:

I/Choreographer(20433): Skipped 53 frames! The application may be doing too much work on its main thread. Restarted application in 1,626ms. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : detach I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Unbind from service. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : detach I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Unbind from service. I/[Purchases] - INFO(20433): Purchases instance already set with the same configuration. Ignoring duplicate call. D/[Purchases] - DEBUG(20433): ℹ️ Listener set I/flutter (20433): RevenueCat successfully configured I/[Purchases] - INFO(20433): Purchases instance already set with the same configuration. Ignoring duplicate call. D/[Purchases] - DEBUG(20433): ℹ️ Listener set I/flutter (20433): RevenueCat successfully configured D/[Purchases] - DEBUG(20433): Retrieving customer info with policy: CACHED_OR_FETCHED D/[Purchases] - DEBUG(20433): ℹ️ Vending CustomerInfo from cache. D/[Purchases] - DEBUG(20433): ℹ️ Checking if cache is stale AppInBackground false D/[Purchases] - DEBUG(20433): Retrieving customer info with policy: CACHED_OR_FETCHED D/[Purchases]

  • DEBUG(20433): ℹ️ Vending CustomerInfo from cache. D/[Purchases] - DEBUG(20433): ℹ️ Checking if cache is stale AppInBackground false I/Choreographer(20433): Skipped 61 frames! The application may be doing too much work on its main thread. I/UserMessagingPlatform(20433): Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("602F11F7562F187035354B6E2A33C8BF") to set this as a debug device. D/UserMessagingPlatform(20433): Stored info not exists: IDFA_freqCapNumViews D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_TCString D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAnalyticsStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdPersonalizationPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdUserDataPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_AddtlConsent D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_idfaFlowControl D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoManagedByUmpSdk D/TrafficStats(20433): tagSocket(317) with statsTag=0xffffffff, statsUid=-1 D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. W/ServiceBindIntentUtils(20433): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.CACHE D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. W/ServiceBindIntentUtils(20433): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.START W/Ads (20433): Not retrying to fetch app settings I/Choreographer(20433): Skipped 99 frames! The application may be doing too much work on its main thread. D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads
    (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. I/HWUI (20433): Davey! duration=836ms; Flags=1, FrameTimelineVsyncId=351622698, IntendedVsync=780135331082883, Vsync=780136154936331, InputEventId=0, HandleInputStart=780136160020203, AnimationStart=780136160021749, PerformTraversalsStart=780136160022237, DrawStart=780136160365824, FrameDeadline=780135347682883, FrameInterval=780136159862406, FrameStartTime=8321752, SyncQueued=780136160791239, SyncStart=780136160813334, IssueDrawCommandsStart=780136160929993, SwapBuffers=780136166515157, FrameCompleted=780136167950907, DequeueBufferDuration=795126, QueueBufferDuration=212443, GpuCompleted=780136167950907, SwapBuffersCompleted=780136166755595, DisplayPresentTime=17179869185, CommandSubmissionCompleted=780136166515157, W/Ads (20433): Not retrying to fetch app settings D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads
    (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. I/flutter (20433): Received appWidgetId: 60 W/Ads (20433): Not retrying to fetch app settings W/WindowOnBackDispatcher(20433): OnBackInvokedCallback is not enabled for the application. W/WindowOnBackDispatcher(20433): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest. D/InsetsController(20433): hide(ime(), fromIme=false) I/ImeTracker(20433): com.dont_fet_the_weather:45b3974: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN D/UserMessagingPlatform(20433): Action[write]: {"UMP_consentModeValues":"4444","IABTCF_CmpSdkID":300,"IABTCF_gdprApplies":0} D/UserMessagingPlatform(20433): Writing to storage: [UMP_consentModeValues] 4444 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_CmpSdkID] 300 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_gdprApplies] 0 I/UserMessagingPlatform(20433): Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("602F11F7562F187035354B6E2A33C8BF") to set this as a debug device. D/UserMessagingPlatform(20433): Stored info not exists: IDFA_freqCapNumViews D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_TCString D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAnalyticsStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdPersonalizationPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdUserDataPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_AddtlConsent D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_idfaFlowControl D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoManagedByUmpSdk D/UserMessagingPlatform(20433): Action[write]: {"UMP_consentModeValues":"4444","IABTCF_CmpSdkID":300,"IABTCF_gdprApplies":0} D/UserMessagingPlatform(20433): Writing to storage: [UMP_consentModeValues] 4444 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_CmpSdkID] 300 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_gdprApplies] 0 I/Choreographer(20433): Skipped 43 frames! The application may be doing too much work on its main thread. 8 W/Ads (20433): canOpenAppGmsgHandler disabled. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. D/TrafficStats(20433): tagSocket(406) with statsTag=0xffffffff, statsUid=-1 D/TrafficStats(20433): tagSocket(404) with statsTag=0xffffffff, statsUid=-1 I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath 8 W/Ads (20433): canOpenAppGmsgHandler disabled. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. D/TrafficStats(20433): tagSocket(350) with statsTag=0xffffffff, statsUid=-1 I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath D/TrafficStats(20433): tagSocket(397) with statsTag=0xffffffff, statsUid=-1 I/flutter (20433): mph

Not sure what else to debug here. I had a Ads issue for some reason and resolved that but now I am stuck again.

I am implementing Android home screen widgets for the first time and want to open a homescreen widget config screen wehn a user goes to add a widget. WHich I call from here:

class WidgetConfigActivity : FlutterActivity() {

    private var appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d("WidgetConfigActivity", "onCreate invoked")
        val extras = intent.extras
        if (extras != null) {
            appWidgetId = extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID
            )
        }
        Log.d("WidgetConfigActivity", "AppWidgetId: $appWidgetId") // Add this line

        if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
            finish()
        }
    }

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        MethodChannel(
            flutterEngine.dartExecutor.binaryMessenger,
            "widget_config_channel"
        ).setMethodCallHandler { call, result ->
            when (call.method) {
                "finishConfig" -> {
                    val returnIntent = Intent()
                    returnIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
                    setResult(RESULT_OK, returnIntent)
                    finish()
                    result.success(true)
                }
                "getAppWidgetId" -> {
                    // Simply return the appWidgetId stored in this Activity
                    result.success(appWidgetId)
                }
                else -> {
                    result.notImplemented()
                }
            }
        }
    }

    override fun getInitialRoute(): String? {
    return "/widgetConfig"
}
}

I have the route defined in my apps main file here:

 Widget build(BuildContext context) {
    // Provider.of<RevenueCatProvider>(context, listen: false)
    //     .initPlatformPurchaseStateRevenueCat();
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      routes: {
        '/addLocation': (context) => const AddLocation(),
        '/locationDetailsView': (context) => const LocationDetailsView(),
        '/userSettings': (context) => const UserSettings(),
        '/manageLocations': (context) => const ManageLocations(),
        '/myApp': (context) => MyApp(isFirstRun),
        '/manageUnits': (context) => const ManageUnits(),
        '/homePageV2': (context) => const HomePageV2(),
        '/locationDetailsViewV2': (context) => const LocationDetailsViewV2(),
        '/shareForecast': (context) => const ShareForecast(),
        '/widgetConfig': (context) => WidgetConfigScreen(),
      },

When I try to test this in production. Tried both emmulator and real phone I get a dark screen. If I hit hot reload then it resumes form the black screen and actually goes to my config screen. I see this error in my debugg:

I/Choreographer(20433): Skipped 53 frames! The application may be doing too much work on its main thread. Restarted application in 1,626ms. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : detach I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Unbind from service. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : detach I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Unbind from service. I/[Purchases] - INFO(20433): Purchases instance already set with the same configuration. Ignoring duplicate call. D/[Purchases] - DEBUG(20433): ℹ️ Listener set I/flutter (20433): RevenueCat successfully configured I/[Purchases] - INFO(20433): Purchases instance already set with the same configuration. Ignoring duplicate call. D/[Purchases] - DEBUG(20433): ℹ️ Listener set I/flutter (20433): RevenueCat successfully configured D/[Purchases] - DEBUG(20433): Retrieving customer info with policy: CACHED_OR_FETCHED D/[Purchases] - DEBUG(20433): ℹ️ Vending CustomerInfo from cache. D/[Purchases] - DEBUG(20433): ℹ️ Checking if cache is stale AppInBackground false D/[Purchases] - DEBUG(20433): Retrieving customer info with policy: CACHED_OR_FETCHED D/[Purchases]

  • DEBUG(20433): ℹ️ Vending CustomerInfo from cache. D/[Purchases] - DEBUG(20433): ℹ️ Checking if cache is stale AppInBackground false I/Choreographer(20433): Skipped 61 frames! The application may be doing too much work on its main thread. I/UserMessagingPlatform(20433): Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("602F11F7562F187035354B6E2A33C8BF") to set this as a debug device. D/UserMessagingPlatform(20433): Stored info not exists: IDFA_freqCapNumViews D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_TCString D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAnalyticsStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdPersonalizationPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdUserDataPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_AddtlConsent D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_idfaFlowControl D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoManagedByUmpSdk D/TrafficStats(20433): tagSocket(317) with statsTag=0xffffffff, statsUid=-1 D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. W/ServiceBindIntentUtils(20433): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.CACHE D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. W/ServiceBindIntentUtils(20433): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.START W/Ads (20433): Not retrying to fetch app settings I/Choreographer(20433): Skipped 99 frames! The application may be doing too much work on its main thread. D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads
    (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. I/HWUI (20433): Davey! duration=836ms; Flags=1, FrameTimelineVsyncId=351622698, IntendedVsync=780135331082883, Vsync=780136154936331, InputEventId=0, HandleInputStart=780136160020203, AnimationStart=780136160021749, PerformTraversalsStart=780136160022237, DrawStart=780136160365824, FrameDeadline=780135347682883, FrameInterval=780136159862406, FrameStartTime=8321752, SyncQueued=780136160791239, SyncStart=780136160813334, IssueDrawCommandsStart=780136160929993, SwapBuffers=780136166515157, FrameCompleted=780136167950907, DequeueBufferDuration=795126, QueueBufferDuration=212443, GpuCompleted=780136167950907, SwapBuffersCompleted=780136166755595, DisplayPresentTime=17179869185, CommandSubmissionCompleted=780136166515157, W/Ads (20433): Not retrying to fetch app settings D/DynamitePackage(20433): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads
    (20433): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("602F11F7562F187035354B6E2A33C8BF")) to get test ads on this device. I/flutter (20433): Received appWidgetId: 60 W/Ads (20433): Not retrying to fetch app settings W/WindowOnBackDispatcher(20433): OnBackInvokedCallback is not enabled for the application. W/WindowOnBackDispatcher(20433): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest. D/InsetsController(20433): hide(ime(), fromIme=false) I/ImeTracker(20433): com.dont_fet_the_weather:45b3974: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN D/UserMessagingPlatform(20433): Action[write]: {"UMP_consentModeValues":"4444","IABTCF_CmpSdkID":300,"IABTCF_gdprApplies":0} D/UserMessagingPlatform(20433): Writing to storage: [UMP_consentModeValues] 4444 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_CmpSdkID] 300 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_gdprApplies] 0 I/UserMessagingPlatform(20433): Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("602F11F7562F187035354B6E2A33C8BF") to set this as a debug device. D/UserMessagingPlatform(20433): Stored info not exists: IDFA_freqCapNumViews D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_TCString D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAnalyticsStoragePurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdPersonalizationPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoAdUserDataPurposeConsentStatus D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_AddtlConsent D/UserMessagingPlatform(20433): Stored info not exists: IABTCF_idfaFlowControl D/UserMessagingPlatform(20433): Stored info not exists: UMP_CoMoManagedByUmpSdk D/UserMessagingPlatform(20433): Action[write]: {"UMP_consentModeValues":"4444","IABTCF_CmpSdkID":300,"IABTCF_gdprApplies":0} D/UserMessagingPlatform(20433): Writing to storage: [UMP_consentModeValues] 4444 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_CmpSdkID] 300 D/UserMessagingPlatform(20433): Writing to storage: [IABTCF_gdprApplies] 0 I/Choreographer(20433): Skipped 43 frames! The application may be doing too much work on its main thread. 8 W/Ads (20433): canOpenAppGmsgHandler disabled. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. D/TrafficStats(20433): tagSocket(406) with statsTag=0xffffffff, statsUid=-1 D/TrafficStats(20433): tagSocket(404) with statsTag=0xffffffff, statsUid=-1 I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath 8 W/Ads (20433): canOpenAppGmsgHandler disabled. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. D/TrafficStats(20433): tagSocket(350) with statsTag=0xffffffff, statsUid=-1 I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : prewarm(com.dont_fet_the_weather) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : Initiate binding to the service. I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.prewarmservice.PrewarmService}) I/PlayCore(20433): UID: [10530] PID: [20433] PrewarmService : linkToDeath D/TrafficStats(20433): tagSocket(397) with statsTag=0xffffffff, statsUid=-1 I/flutter (20433): mph

Not sure what else to debug here. I had a Ads issue for some reason and resolved that but now I am stuck again.

Share Improve this question asked Mar 28 at 1:19 Ten Digit GridTen Digit Grid 2,7297 gold badges37 silver badges58 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

in my WidgetConfigActivity.kt I added a simple delay and it resolved the issue:

Snippet that resolved the issue:

// Add a delay to ensure everything is fully initialized
        Handler(Looper.getMainLooper()).postDelayed({
            setupWidgetConfiguration()
        }, 100)

Full Code:

package com.dont_fet_the_weather

import android.os.Handler
import android.os.Looper
import android.util.Log
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.pluginmon.MethodChannel

class WidgetConfigActivity : FlutterActivity() {
    private var appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        Log.e("WidgetConfigActivity", "=== FULL ONCREATE START ===")
        
        // Add a delay to ensure everything is fully initialized
        Handler(Looper.getMainLooper()).postDelayed({
            setupWidgetConfiguration()
        }, 100)
    }

    private fun setupWidgetConfiguration() {
        Log.e("WidgetConfigActivity", "Setup Widget Configuration")
        
        val extras = intent.extras
        if (extras != null) {
            appWidgetId = extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID
            )
            Log.e("WidgetConfigActivity", "Extracted AppWidgetId: $appWidgetId")
        } else {
            Log.e("WidgetConfigActivity", "No extras found in intent")
        }
        
        if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
            Log.e("WidgetConfigActivity", "Invalid AppWidgetId, finishing activity")
            finish()
            return
        }
    }

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        
        Log.e("WidgetConfigActivity", "Configuring Flutter Engine")
        
        MethodChannel(
            flutterEngine.dartExecutor.binaryMessenger,
            "widget_config_channel"
        ).setMethodCallHandler { call, result ->
            when (call.method) {
                "finishConfig" -> {
                    Log.e("WidgetConfigActivity", "Finishing configuration")
                    val returnIntent = Intent()
                    returnIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
                    setResult(RESULT_OK, returnIntent)
                    finish()
                    result.success(true)
                }
                "getAppWidgetId" -> {
                    Log.e("WidgetConfigActivity", "Returning AppWidgetId: $appWidgetId")
                    result.success(appWidgetId)
                }
                else -> {
                    Log.e("WidgetConfigActivity", "Unhandled method: ${call.method}")
                    result.notImplemented()
                }
            }
        }
    }

    override fun getInitialRoute(): String? {
        Log.e("WidgetConfigActivity", "Getting initial route")
        return "/widgetConfig"
    }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论