From 559b98f0b1a89ff4d2353528f13af43c65197a09 Mon Sep 17 00:00:00 2001 From: Marc Dietrichstein Date: Sun, 27 Mar 2011 13:44:40 +0200 Subject: [PATCH] new rake task 'run': starts the program via 'adb shell' --- lib/pindah.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pindah.rb b/lib/pindah.rb index 5f17111..ca9ed57 100644 --- a/lib/pindah.rb +++ b/lib/pindah.rb @@ -2,6 +2,7 @@ require "fileutils" require "pp" require "erb" +require "rexml/document" begin require 'ant' @@ -43,6 +44,14 @@ def self.infer_sdk_location(path) pp @spec end + desc "Run the project debug .apk on a device or emulator" + task :run => [:install] do + manifest_xml = REXML::Document.new(File.new("AndroidManifest.xml")) + package_name = manifest_xml.root.attributes["package"] + main_activity = REXML::XPath.first(manifest_xml, "//application/activity[intent-filter[action[@android:name='android.intent.action.MAIN']]]/attribute::android:name").value + system "adb shell 'am start -a android.intent.action.MAIN -n #{package_name}/#{package_name}.#{main_activity}'" + end + task :default => [:install] def self.spec=(spec)