kvdroid / Kvdroid

Some Pyjnius tools for Kivy-Android developments.
MIT License
94 stars 24 forks source link

launch_app_activity and launch_app doesnt work from a serviceforeground on Android 13 #58

Closed TirrouOussama closed 6 months ago

TirrouOussama commented 6 months ago

13 14 15

from kvdroid.tools import launch_app
from kvdroid.tools.package import all_main_activities
from kvdroid.tools.package import package_info
from kvdroid.tools import launch_app_activity
while True:
    time.sleep(30)

    s = all_main_activities()
    print('this is my the activity in the background____:',s[-1])

    print('______________________________________lunch activity method')
    launch_app_activity('org.syncinterpck.syncinter', 'org.kivy.android.PythonActivity')   
    print('_______________________________________lunch app method')
    launch_app("org.syncinterpck.syncinter")
    print('app started')

    # this the debug of of the service foreground

    # adb logcat -s Lunaser3       
    # 01-05 21:29:27.479 11165 11187 I Lunaser3: this is my the activity in the background____: {'org.syncinterpck.syncinter': 'org.kivy.android.PythonActivity'}
    # 01-05 21:29:27.479 11165 11187 I Lunaser3: ______________________________________lunch activity method
    # 01-05 21:29:27.493 11165 11187 I Lunaser3: _______________________________________lunch app method
    # 01-05 21:29:27.501 11165 11187 I Lunaser3: app started

after i start the app manually and sent it back with the home screen it doesnt start from the service

12

kengoon commented 6 months ago

@TirrouOussama Starting from android 10 up, android does not allow launching an activity from a non visible window https://developer.android.com/guide/components/activities/background-starts#exceptions

You can allow the user of the app to manually launch the activity from a notification.

TirrouOussama commented 6 months ago

@kengoon yes i have read that. and about the notif its just not the way to go. i have to go back to the app like receiving a call (whasup messenger viber). i guess i ll try recent tasks

kengoon commented 6 months ago

@TirrouOussama I don't understand what you mean. But so you know, the notification function here on kvdroid allows you to launch your app when you tap on it. You can read Google docs for further issues.

I will be closing this issue as not planned because it's a third party issue and not kvdroid issue.

TirrouOussama commented 6 months ago

@kengoon like the plyer notif when u tap on it u go to the app but to be be able to start the app directly without any manual interaction is the problem i face relation to the app _launch

kengoon commented 6 months ago

@TirrouOussama that's called hijacking a users phone activity without their consent . And that's why android made it impossible to launch any when the app is not visible itself. There's nothing you can do about it. Consider allowing the user to manually launch your app when they tap on your notification.

TirrouOussama commented 6 months ago

@kengoon thank you. close it. and if i find any solution i ll email you.