Finish all activities in Basic4Android - basic4android

I have an application with many activities, sharing the same Menu, which is created in a code module. This Menu has an option "Exit". How do I finish all running activities without using ExitApplication? Do I have to create a variable in the code module (ExitNow as boolean) and check it in every Activity_Resume of every activity?

put activity.finish as the code for your exit button

try this one.
Intent intent = new Intent(getApplicationContext(), Home.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

type this in prossec global :
Dim GExit as boolean
Gexit= false
type in all resume in all activity this code:
if Gexit = true then activity.finish
and type this code in your BTNEXIT:
Gexit= true
activity.finish

I tried a lot of examples but this really worked for me
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Related

How to pass ability in Harmony using Intent

I was trying to pass ability like we pass in android
Intent intent = new Intent(HomeActivity.this, cls);
But in Harmony we have to use operation builder so used this method
intent = new Intent();
Operation operation = new Intent.OperationBuilder().withBundleName(ability.getBundleName()).withAbilityName(name.toString()).build();
intent.setOperation(operation);
Here 'name' variable is class name.
I just wanted to know that is this the equivalent of the above android code.
If not then what is the correct way
You can construct an Operation object with bundleName and abilityName specified to start and navigate to the particular ability. The sample code snippet is as follows:
Intent intent = new Intent();
// Use the OperationBuilder class of Intent to construct an Operation object and set the deviceId (left empty if a local ability is required), bundleName, and abilityName attributes for the object.
Operation operation = new Intent.OperationBuilder()
.withDeviceId("")
.withBundleName("com.demoapp")
.withAbilityName("com.demoapp.FooAbility")
.build();
// Set the created Operation object to the Intent as its operation attribute.
intent.setOperation(operation);
startAbility(intent);
For more details, pls refer to this Docs.

how to handle Alexa Echo Show built-in intent

According to the echo show documentation, ONLY the AMAZON.PreviousIntent, and AMAZON.MoreIntent have to be handled by the skill developer.
I've written the following code for them, but Alexa says an error occurred when invoking both previous and next intents on the echo show.
SpeechletResponse speechletResp = new SpeechletResponse();
DelegateDirective dd = new DelegateDirective();
List<Directive> directiveList = new ArrayList<>();
directiveList.add(dd);
speechletResp.setDirectives(directiveList);
speechletResp.setNullableShouldEndSession(null);
return speechletResp;
Any idea how to fix this?
I think the error is curring here:
speechletResp.setNullableShouldEndSession(null);
You should set if the session will end or not, with a true or false.

sahi onScriptFailure doesn't seem to work

I am new to Sahi and I am just trying to take a screenshot on script errors.
I have tried to used their demo and the script the website provides for the task, but the onScriptFailure doesn't seem to trigger. I added the alert box and changed the log in name to trigger a failure. Sorry if i'm missing something obvious.
function onScriptError($e){
_focusWindow();
_takeScreenShot();
_alert("test me");
}
onScriptFailure = onScriptError;
_navigateTo("http://sahi.co.in/demo/training/");
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("TriggerError"));
I was using Sahi Pro. I actually got the answer from their support department. This is what he had me do:
var onScriptError = function ($e) {
_focusWindow();
_takeScreenShot();
_alert("test me");
}
onScriptFailure = onScriptError;
_navigateTo("http://sahi.co.in/demo/training/");
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("TriggerError"));
HI You can use the GlobalInclude.sah file which has the code for the error handling.
you can edit this file to make the script behave according to your needs

Making VB Browser Make Facebook Status

I am trying to make a vb script to log into my facebook and update my status. The problem is, the submit button does not have an ID I can find using the page info with Chrome. The script I have so far is:
Try
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("pathtotext") ' I sensoored my path
fileReader2 = My.Computer.FileSystem.ReadAllText("pathtotext") 'I sensored my path
WebBrowser1.Document.GetElementById("email").SetAttribute("value", fileReader2)
WebBrowser1.Document.GetElementById("pass").SetAttribute("value", fileReader)
WebBrowser1.Document.GetElementById("loginbutton").InvokeMember("click")
Catch ex As Exception
WebBrowser1.Document.GetElementById("u_0_10").SetAttribute("value", "Can I make a status?")
WebBrowser1.Document.GetElementById("submit").InvokeMember("click")
End Try
All of this works, except the submit button. I used "submit" because that was the type and no ID is showing up. Thanks in advance for all help.
P.S - For future reference, how did you find the id for this button? "If you give a starving man a fish he shall be filled; teach him to fish, however and he shall never go hungry again" - Anonymous
you can use this
Dim htmlElements As HtmlElementCollection = WebBrowser1.Document.All
For Each ClickOnElementButton As HtmlElement In htmlElements
If ClickOnElementButton.InnerText = "Post" Then
ClickOnElementButton.InvokeMember("click")
End If
Next
instead of the old code

Trigger formatter in a custom plug-in in Eclipse

I writing my own text editor plugin for eclipse. I am now working on my own formatter. Actually, following that link http://wiki.eclipse.org/FAQ_How_do_I_support_formatting_in_my_editor%3F.
I have written my Strategy, I have overridden getContentFormatter in my SourceViewerConfiguration..
As I run my plugin and press Ctrl+Shift+F - and nothing happens.
I think that I'm missing a step here. Should I create a handler or something?
Thanks
Might it be you skipped the last part of the linked page?
Finally, you will need to create an action that invokes the formatter. No generic formatting action is defined by the text infrastructure, but it is quite easy to create one of your own. The action’s run method can simply call the following on the source viewer to invoke the formatter:
sourceViewer.doOperation(ISourceViewer.FORMAT);
What helped me. I have created a handler with the following executors body:
//get the editorPart
if (editorPart != null) {
ITextOperationTarget target = (ITextOperationTarget) editorPart
.getAdapter(ITextOperationTarget.class);
if (target instanceof ISourceViewer) {
ISourceViewer textViewer = (ISourceViewer) target;
((ITextOperationTarget) textViewer)
.doOperation(ISourceViewer.FORMAT);
}
}
Then just create menu items and bind them to the handler.