22
33from kivy .app import App
44from kivy .utils import platform
5+ if platform == 'android' :
6+ from jnius import autoclass , cast
7+ JS = autoclass ('java.lang.String' )
8+ Intent = autoclass ('android.content.Intent' )
9+ PythonActivity = autoclass ('org.kivy.android.PythonActivity' )
10+ currentActivity = cast ('android.app.Activity' , PythonActivity .mActivity )
511
612
713def pause_app ():
814 '''
915 '''
1016 if platform == 'android' :
11- from jnius import cast
12- from jnius import autoclass
13- PythonActivity = autoclass ('org.kivy.android.PythonActivity' )
1417 currentActivity = cast (
1518 'android.app.Activity' , PythonActivity .mActivity )
1619 currentActivity .moveTaskToBack (True )
@@ -19,19 +22,27 @@ def pause_app():
1922 app .stop ()
2023
2124
25+ def set_reminder (self , title , time ):
26+ intent = Intent ()
27+ Calendar = autoclass ('java.util.Calendar' )
28+ calendar = Calendar .getInstance ()
29+ calendar .setTimeInMillis (1480103863835 )
30+ intent .setType ("vnd.android.cursor.item/event" )
31+ intent .putExtra (Events .DESCRIPTION , "Download Examples" )
32+ intent .putExtra ("title" , "A Test Event from android app" );
33+ intent .setAction (Intent .ACTION_VIEW )
34+ PythonActivity .mActivity .startActivity (intent )
35+
36+
2237def do_share (data , title ):
2338 if platform != 'android' :
2439 return
25- from jnius import autoclass , cast
26- JS = autoclass ('java.lang.String' )
27- Intent = autoclass ('android.content.Intent' )
2840 sendIntent = Intent ()
2941 sendIntent .setAction (Intent .ACTION_SEND )
3042 sendIntent .setType ("text/plain" )
3143 sendIntent .putExtra (Intent .EXTRA_TEXT , JS (data ))
32- PythonActivity = autoclass ('org.kivy.android.PythonActivity' )
33- currentActivity = cast ('android.app.Activity' , PythonActivity .mActivity )
34- it = Intent .createChooser (sendIntent , cast ('java.lang.CharSequence' , JS (title )))
44+ it = Intent .createChooser (
45+ sendIntent , cast ('java.lang.CharSequence' , JS (title )))
3546 currentActivity .startActivity (it )
3647
3748
0 commit comments