Skip to content
Snippets Groups Projects
Commit ae81d2d2 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Initial commit.

parents
No related branches found
No related tags found
No related merge requests found
.idea
*.pyc
*.pyo
*.apk
from kivy.utils import platform
from jnius import autoclass
def dial(phone_number):
if platform != 'android':
raise NotImplementedError('Dialing is only supported on Android')
# noinspection PyPep8Naming
Dialer = autoclass('edu.unl.cse.soft161.Dialer')
success = Dialer.dial(phone_number)
if not success:
raise NotImplementedError('Unable to find phone app')
/*
* This file and the enclosing package folders must be symlinked into the p4a dist's src folder.
*
* For example, if you are building for x86, you might run
*
* $ ln -s ~/PycharmProjects/intents/edu ~/.local/share/python-for-android/dists/x86/src/edu
*
*/
package edu.unl.cse.soft161;
import org.kivy.android.PythonActivity;
import android.content.Intent;
import android.net.Uri;
import android.app.Activity;
public class Dialer {
public static boolean dial(String phoneNumber) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + phoneNumber));
Activity activity = PythonActivity.mActivity;
if (intent.resolveActivity(activity.getPackageManager()) != null) {
activity.startActivity(intent);
return true;
}
return false;
}
}
BoxLayout:
orientation: 'vertical'
Label:
id: error
Button:
text: 'Call Clinic'
on_press: app.call_clinic()
main.py 0 → 100644
from kivy.app import App
from dialing import dial
__app_package__ = 'edu.unl.cse.soft161.intents'
__app__ = 'Intents'
__version__ = '0.1'
__flags__ = ['--bootstrap=sdl2', '--requirements=python2,kivy,pyjnius', '--orientation=landscape']
class IntentApp(App):
def call_clinic(self):
try:
dial('5555555555')
except NotImplementedError as exception:
self.root.ids.error.text = 'Cannot dial: {exception}'.format(exception=exception)
if __name__ == "__main__":
app = IntentApp()
app.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment