Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – is it possible to get activity in TileService?

Posted on November 11, 2022 By

Solution 1 :

Im trying to launch a method from the onClick method on TileService , but my method require the activity object , i didn’t figure out how to get it on TileService

There may not be an Activity object. There is no requirement for you to have a running process at the time the user clicks on your tile.

I am using Media Projection Api , for exemple the startActivityForResult needs the activity

You probably can call startActivity() from a tile. So, call startActivity() for some activity of yours, and that can call startActivityForResult() to start the media projection confirmation dialog.

Problem :

Im trying to launch a method from the onClick method on TileService , but my method require the activity object , i didn’t figure out how to get it on TileService


@RequiresApi(Build.VERSION_CODES.N)
class TileService:TileService() {
    val TAG ="Tile"


 
    // Called when the user taps on your tile in an active or inactive state.
    override fun onClick() {
        super.onClick()
        Log.d(TAG, "onClick: ")
        Toast.makeText(application, "hello world", Toast.LENGTH_SHORT).show()

        AppHelper.getInstance().startMethod("Here i need activity object ")

    }
    // Called when the user removes your tile.
    override fun onTileRemoved() {
        super.onTileRemoved()
        Log.d(TAG, "onTileRemoved: ")
    }

}

Comments

Comment posted by TheLibrarian

The answer to the question is No. There is a lot of reasons why. What do you need the activity for?

Comment posted by Anas Hafidi

I am using Media Projection Api , for exemple the startActivityForResult needs the activity

Comment posted by TheLibrarian

With newer APIs you are not allowed to start activity from background.

READ  [FIXED] android - gradle sync ok, but cant't build the project
Powered by Inline Related Posts
Android Tags:android, kotlin

Post navigation

Previous Post: [FIXED] java – App crash after uploaded to play store , working correctly when installed from android studio
Next Post: What is the 21 day fitness challenge?

Related Posts

[FIXED] android – RecyclerView places a horrible space between each element Android
[FIXED] json – Android how to know when database has finished creating in MVVM Android
[FIXED] java – Is it possible to kill an app from recent apps screen by swiping using Appium on Android? Android
[FIXED] android – Kotlin Show my list elements from bottom to top in lazy column Android
[FIXED] android – ‘java.lang.ClassNotFoundException: Didn’t find class “org.apache.http.client.ClientProtocolException”‘ after migrating to target API Level 28 Android
[FIXED] android – Are App Permissions confined to specific Activities? Android

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can Vicks humidifier be used without filter?
  • What color is Spanish green?
  • How old is Jamie in The War That Saved My Life?
  • When should I use scalp massager for hair growth?
  • Can I put polyurethane over liming wax?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme