Plack on SL4A in Yokohama.pm #8

3,555 views

Published on

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total views
3,555
On SlideShare
0
From Embeds
0
Number of Embeds
33
Actions
Shares
0
Downloads
5
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Plack on SL4A in Yokohama.pm #8

    1. 1. Plack on SL4A clouder
    2. 2. Whats SL4A?• Scripting Layer for Android• Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported• Access to UI, Camera, Sensors on Android• Shibuya.pm #14 http://d.hatena.ne.jp/naoya/20100930/1285868397• http://advent.perl.kr/2010-12-21.html
    3. 3. Try installing the Plack
    4. 4. SL4A installation• Android SDK apk http://code.google.com/p/android-scripting/ % adb install sl4a_r4.apk 2546 KB/s (858471 bytes in 0.329s) pkg: /data/local/tmp/sl4a_r4.apk Success
    5. 5. Shell
    6. 6. Interpriter installation•
    7. 7. Perl
    8. 8. It works!• Perl debugger
    9. 9. Run script• hello_world.pl use Android; my $android = Android->new; $android->makeToast(“Hello, Android!”);
    10. 10. hello_work.pl
    11. 11. Directory structure• @INC /data/data/com.googlecode.perlforandroid/files/perl/ site_perl/5.10.0/arm-eabi-linux /sdcard/com.googlecode.perlforandroid/extras/perl/ site_perl/5.10.0 /data/data/com.googlecode.perlforandroid/files/perl/5.10.0/ arm-eabi-linux /data/data/com.googlecode.perlforandroid/files/perl/5.10.0 /sdcard/com.googlecode.perlforandroid/extras/perl/site_perl .• /sdcard/sl4a/scripts
    12. 12. Plack installation• Android SD PC Plack DST=/mnt/sdcard/sl4a/scripts cpanm -l $DST/perl5 --reinstall -qfn CGI CGI::Util HTTP::Date Time::Local URI::Escape Plack::Builder Plack::App::Directory HTTP::Server::Simple::CGI HTTP::Server::Simple::PSGI HTTP::Message HTTP::Body Hash::MultiValue
    13. 13. Plack installation(con’t)mkdir -p $DST/lib/perl5/File/Speccp `perldoc -l File::Spec::Unix` $DST/lib/perl5/File/Speccp `perldoc -l integer` $DST/lib/perl5cp `perldoc -l parent` $DST/lib/perl5cp `perldoc -l DirHandle` $DST/lib/perl5cp `perldoc -l FileHandle` $DST/lib/perl5
    14. 14. Script using Plack use strict; use lib /sdcard/sl4a/scripts/perl5/lib/perl5; use Android; use Plack::Builder; use Plack::App::Directory; use HTTP::Server::Simple::PSGI;• my $droid Plack = Android->new; my $app = builder { mount "/" => Plack::App::Directory->new(root => /sdcard); }; my $server = HTTP::Server::Simple::PSGI->new(8080); $server->app($app); $server->run;
    15. 15. Transfer script• Android % adb push filer.pl /sdcard/sl4a/scripts/filer.pl
    16. 16. Start server before run
    17. 17. Server works!
    18. 18. Demo
    19. 19. Impressions• XS make•• SL4A Perl Perl

    ×