startActivity

postado em 25 de jun de 2012 17:54 por Silvio Garbes   [ 28 de jun de 2012 07:45 atualizado‎(s)‎ ]
startActivity(
 
String action,
 
String uri[optional],
 
String type[optional]: MIME type/subtype of the URI,
 
JSONObject extras[optional]: a Map of extras to add to the Intent,
 
Boolean wait[optional]: block until the user exits the started activity,
 
String packagename[optional]: name of package. If used, requires classname to  
be useful
,
 
String classname[optional]: name of class. If used, requires packagename to be
useful
)

Starts an activity.


Exemplo:


This launch the set wallpaper app. 
<?php 
         require_once("Android.php"); 
         $droid = new Android(); 
         $droid->startActivity("android.intent.action.SET_WALLPAPER"); 
         $droid->exit(); 
?> 

----------

And this get the power usage summary app. 
<?php 
        require_once("Android.php"); 
        $droid = new Android(); 
        $droid- 
>startActivity("android.intent.action.POWER_USAGE_SUMMARY"); 
        $droid->exit(); 
?>

---------------

print_r($droid->startActivity("android.intent.action.VIEW","tel:"));
print_r($droid->startActivity("android.intent.action.VIEW","tel:123"));
print_r($droid->sendEmail('',"assunto","teste"));

print_r($droid->startActivity("android.intent.action.VIEW","sms:"));
print_r($droid->startActivity("android.intent.action.VIEW","sms:123"));
print_r($droid->startActivity("android.intent.action.VIEW","smsto:123"));
$arr = array("sms_body" => "teste");
print_r($droid->startActivityForResult("android.intent.action.VIEW",null,"vnd.android-dir/mms-sms",$arr));
print_r($droid->startActivity("android.intent.action.VIEW",NULL,"vnd.android-dir/mms-sms",$arr));

print_r($droid->startActivity("android.intent.action.VIEW","mailto:"));
print_r($droid->startActivity("android.intent.action.VIEW","mailto:silviogarbes@gmail.com"));
print_r($droid->startActivity("android.intent.action.INSERT","content://contacts/people"));

-----------

$html = "<html><body>
<h1>Battery Status</h1>
<ul>
<li><strong>Status: s</li>
<li><strong>Temperature: s</li>
<li><strong>Level: s</li>
<li><strong>Plugged In: s</li>
</ul>
</body></html>";

$arquivo = '/sdcard/sl4a/scripts/battstats.html';
$fp = fopen($arquivo, 'w');
fwrite($fp, $html);
fclose($fp);

$droid->startActivity("android.intent.action.VIEW", "file:///sdcard/sl4a/scripts/battstats.html", "text/html");

-----------------

ExtensionMIME Type
Android Application.apkapplication/vnd.android.package-archive
Text.txttext/plain
.csvtext/csv
.xmltext/xml
Web related.htmtext/html
.htmltext/html
.phptext/php
Image.pngimage/png
.gifimage/gif
.jpgimage/jpg
.jpegimage/jpeg
.bmpimage/bmp
Audio.mp3audio/mp3
.wavaudio/wav
.oggaudio/x-ogg
.midaudio/mid
.midiaudio/midi
.amraudio/AMR
Video.mpegvideo/mpeg
.3gpvideo/3gpp
Package.jarapplication/java-archive
.zipapplication/zip
.rarapplication/x-rar-compressed
.gzapplication/gzip

-----------------


Comments