Closed

Description
@EmmaCaunter commented on May 4, 2018, 6:17 PM UTC:
Versions
- Python: 2.7
- OS: Android
- Kivy: master
- Kivy installation method: Git
Description
When the app is in the background, I want to use Android's Intent to bring app back to top. When the intent activates, the app instantly crashes and then restarts. This issue occurs with the new toolchain but not with the old one.
Code and Logs
Code to replicate:
***************
from kivy.app import App
from kivy.uix.button import Button
from android.broadcast import BroadcastReceiver
from jnius import autoclass
from plyer.platforms.android import SDK_INT
PythonActivity = autoclass('org.kivy.android.PythonActivity')
NotificationBuilder = autoclass('android.app.Notification$Builder')
Context = autoclass('android.content.Context')
Intent = autoclass('android.content.Intent')
PendingIntent = autoclass('android.app.PendingIntent')
Uri = autoclass('android.net.Uri')
Notification = autoclass('android.app.Notification')
AndroidString = autoclass('java.lang.String')
class TestApp(App):
def build(self):
return Button(text='Hello World')
def on_resume(self):
print "On resume"
def on_pause(self):
print "on pause"
activity = PythonActivity.mActivity
Drawable = autoclass("{}.R$drawable".format(activity.getPackageName()))
notification_service = activity.getSystemService(Context.NOTIFICATION_SERVICE)
icon = getattr(Drawable, 'icon')
noti = NotificationBuilder(activity)
noti.setPriority(Notification.PRIORITY_MAX)
noti.setDefaults(Notification.DEFAULT_ALL)
noti.setContentTitle(AndroidString(("title").encode('utf-8')))
noti.setContentText(AndroidString(("message").encode('utf-8')))
noti.setSmallIcon(icon)
id = 22701
app_intent = Intent(Intent.ACTION_PROVIDER_CHANGED)
pending_intent = PendingIntent.getBroadcast(activity, id, app_intent, PendingIntent.FLAG_UPDATE_CURRENT)
app_intent.setData(Uri.parse('close'))
if not hasattr(self, 'br'):
self.broadcast_receiver = BroadcastReceiver(
self.on_broadcast, actions=['provider_changed', 'run'])
self.broadcast_receiver.start()
noti.addAction(0, AndroidString("Start"), pending_intent)
if SDK_INT >= 16:
noti = noti.build()
else:
noti = noti.getNotification()
notification_service.notify(0, noti)
return True
def on_broadcast(self, context, intent):
print "On Broadcast"
activity = PythonActivity.mActivity
notification_service = activity.getSystemService(Context.NOTIFICATION_SERVICE)
notification_service.cancel(0)
intent = Intent(activity.getApplicationContext(), PythonActivity)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
activity.getApplicationContext().startActivity(intent)
TestApp().run()
**************
Put app into background, which triggers notification. Touch notification to re-open app, and the app crashes with the following error:
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 7199 (SDLThread)
More detailed logging reveals the following SIGSEGV fingerprint:
04-30 15:53:41.350 3138-3269/? I/bt-btm: BTM_CheckAdvData type=0x19
04-30 15:53:41.350 3138-3269/? I/bt-btm: BTM_CheckAdvData type=0x03
04-30 15:53:41.350 3138-3269/? D/bt-btm: BR/EDR NOT support bit not set, treat as DUMO
04-30 15:53:41.350 458-458/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-30 15:53:41.350 458-458/? I/DEBUG: Build fingerprint: 'htc/bm/htc_m8:5.0.1/LRX22C/463267.2:user/release-keys'
04-30 15:53:41.350 458-458/? I/DEBUG: Revision: '0'
04-30 15:53:41.350 458-458/? I/DEBUG: ABI: 'arm'
04-30 15:53:41.350 458-458/? I/DEBUG: pid: 9964, tid: 10051, name: SDLThread >>> com.test.example <<<
04-30 15:53:41.360 458-458/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
04-30 15:53:41.360 458-458/? I/DEBUG: r0 a0e3e108 r1 a0e3e108 r2 fffffc7c r3 00000000
04-30 15:53:41.360 458-458/? I/DEBUG: r4 00000001 r5 97eb9ae8 r6 9dd4ee40 r7 00000001
04-30 15:53:41.360 458-458/? I/DEBUG: r8 00000001 r9 97eb9ae8 sl 00000001 fp b3e620c0
04-30 15:53:41.360 458-458/? I/DEBUG: ip a0e5fb00 sp 97eb5810 lr a0da36f9 pc a0da31dc cpsr 600b0030
04-30 15:53:41.370 458-458/? I/DEBUG: backtrace:
04-30 15:53:41.370 458-458/? I/DEBUG: #00 pc 000c61dc /data/app/com.test.example-1/lib/arm/libpython2.7.so (PySys_GetObject+11)
04-30 15:53:41.370 458-458/? I/DEBUG: #01 pc 000c66f5 /data/app/com.test.example-1/lib/arm/libpython2.7.so (PySys_SetArgvEx+84)
04-30 15:53:41.440 3138-3269/? I/bt-hci: BLE HCI(id=62) event = 0x02)
04-30 15:53:41.440 3138-3269/? I/bt-hci: btu_ble_process_adv_pkt
04-30 15:53:41.440 <
50AB
span class="pl-c1">3138-3269/? D/bt-btm: btm_ble_process_adv_pkt:bda= 28:39:5e:4f:c9:b7
This issue was moved by tshirtman from kivy/kivy/issues/5728.
Metadata
Metadata
Assignees
Labels
No labels