How to close a app using droidscript?

307 views
Skip to first unread message

Caiota

unread,
Sep 15, 2019, 9:50:46 PM9/15/19
to DroidScript
Como fechar um aplicativo usando droidscript? eu tentei isso e não funciona.

Anotação 2019-09-15 225019.png


Paulo Sergio

unread,
Sep 16, 2019, 10:30:38 AM9/16/19
to DroidScript
var menu;

//Called when application is started.
function OnStart()
{
app.EnableBackKey(false);
//Create a layout with objects vertically centered.
var lay = app.CreateLayout( "linear", "VCenter,FillXY" );

//Create a button to launch the menu
var btn = app.CreateButton( "Show Menu", 0.6, 0.1 );
btn.SetOnTouch( showMenu );
lay.AddChild( btn );

//Add layout to app.
app.AddLayout( lay );

//create a menu dialog.
menu = createMenu("Exit");
menu.SetList("Exit,Model,OSversion");
}

//Create a menu dialog
function createMenu(list)
{
//Create dialog window.
var dlg = app.CreateDialog( "Menu" );

//Create a layout for dialog.
var layDlg = app.CreateLayout( "linear", "vertical,fillxy,left" );
layDlg.SetPadding( 0.02, 0, 0.02, 0.02 );
dlg.AddLayout( layDlg );

//Create a list control and add to dialog
var lstDlg = app.CreateList( list, 0.8, 0.6 );
lstDlg.SetTextSize( 22 );
lstDlg.SetTextColor( "#dddddd" );
lstDlg.SetOnTouch( OnMenu );
layDlg.AddChild( lstDlg );

//need a SetList function for changes to menu
dlg.SetList=function(lst)
{
lstDlg.SetList(lst)
}
//GetList function useful for adding to menu
dlg.GetList=function()
{
return lstDlg.GetList(",")
}
return dlg
}

function showMenu()
{
menu.Show();
}

//Handle list item selection.
function OnMenu( item )
{
//Hide the dialog window.
menu.Hide();
if(item==null)
{
showMenu();
return;
}
switch(item)
{
case "Exit":
app.Exit();
break;
case "Model":
app.ShowPopup(app.GetModel());
break;
case "OSversion":
app.ShowPopup("API level "+app.GetOSVersion());
break;
default:
app.Alert(item+" is not a valid option");
}
}

function OnBack()
{
showMenu();
}

Steve Garman

unread,
Sep 16, 2019, 11:04:41 AM9/16/19
to DroidScript
That looks a lot like something I posted in 2015 https://groups.google.com/d/msg/androidscript/jGHcdDF0gr0/CFkWlhJ7x8oJ

Is there some reason you are posting it now?

Symbroson

unread,
Sep 16, 2019, 11:06:10 AM9/16/19
to DroidScript
You cannot close other processes than your own without root.
And as far as I know there is no CLOSE intent provided by android.

Steve Garman

unread,
Sep 16, 2019, 11:07:37 AM9/16/19
to DroidScript
Strange.

The message Paulo was replying to was not showing on my device till after I repled to him.

Reply all
Reply to author
Forward
0 new messages