How can I make the user copies a text and gets notified? - android-studio

In one of my activities I have this Button:
Button
I want that once the user clicks on the button two things happen:
User copies an email.
User gets notified that he copies an email.
So how can I do it?
Thanks in advance ^_^

To copy a text to a clipboard The Android clipboard framework
And for a simple notification you can use Toast.
So for example:
mailBtn.setOnClickListener {
// Gets a handle to the clipboard service.
val clipboard = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip: ClipData = ClipData.newPlainText("email", "email#email.com")
// Set the clipboard's primary clip.
clipboard.setPrimaryClip(clip)
//Notify user.
Toast.makeText(requireContext(),"Email copied", Toast.LENGTH_LONG).show()
}

Related

How to open a hyperlink in separate browser tab in Coded UI

I have three different Hyperlinks on a web page
Planning.
Solutions.
Contact Us.
I want to open them in separate browser tab one by one using codedUI.
i have written the above code to obtain the list of Hyperlink
HtmlControl Hyperlink = new HtmlControl(browser);
Hyperlink.SearchProperties.Add(HtmlControl.PropertyNames.ControlType,"Hyperlink");
UITestControlCollection controls = Hyperlink.FindMatchingControls();
foreach(UITestControl control in controls)
{
if (control is HtmlHyperlink)
{
HtmlHyperlink link = (HtmlHyperlink)control;
if(link.InnerText=="Planning"|| link.InnerText== "Solutions")
{
//separate Tab logic goes here
}
}
}
I need the help related to opening a hyperlink in new browser tab. Is it possible in CodedUI ?
By default if you click the mouse middle button (or click the scroll wheel), it opens a link in new tab. I would modify your code as below in this case,
if(link.InnerText=="Planning"|| link.InnerText== "Solutions")
{
//Open Link in New tab, by clicking middle button
Mouse.Click(link, MouseButtons.Middle);
}
You can do this a couple different ways. I would use #Prageeth-Saravan 's approach first to see if it works because it's easier and actually tests your UI. You could also:
Get the URL from the found link control
Send the "New tab" keyboard shortcut
Reinstantiate your browser window object to be sure it's pointing to the new tab
Navigate to that URL
The reason why I bolded step 3 is regardless of approach, if you intend to assert or interact with anything in a new tab you're going to have to remember that the CodedUI software will still be "Looking" at the old tab until you reinitialize it.

how to add textfield in dialog box

I wish to save information entered by user on my form using a dialogue box.
Dialog d=new.dialog();
d.show("save info","Do you want to save?","OK","Cancel");
Can i add a textfield (edit-textbox) in the dialog box for the user to enter the desired name (alphanumeric) before pressing ok. and if not interested he can simply cancel. I will be saving the information as a hashtable in an object with user selected name.
If it cannot be done in dialog what is the next best way. pl add a piece of code or tutorial for better understanding.
Its a mobile app developed in Codename one. Therefore, even LWUIT users can help.
thanks
try this:
Textfield myTF = new textfield();
Dialog abc = new Dialog();//how ever u wish to initialize it
abc.addComponenet(myTF);//add text field to dialog
abc.show();//show dialog.
Note: Dialog extends a Form. so u get the propertied of a form in your dialog.

Requesting Advice with parallel programming and webrequest

Currently I have about 20 websites in a list box on my windows form that contain url's.
Each url will navigate to the website download a picture and place the picture into a picture box on the windows form
I have setup 4 picture boxes for the pictures to be entered into.
The user will see the picture of an animal and then will type in the picture and hit a submit button to send the result back to the website for confirmation.
My problem is that when I do try to implement a thread pool I don't have enough time to enter the name of the animal before the next picture loads.
Would it be better for me to create each thread manually and then toggle the button that submits the picture to the site to destroy the thread and grab the next one? I'm very confused. Any help would be awesome.
Thanks
you can use workers to do your background stuff, and a setinterval hack to simulate threads.
start throwing events, and move up the thread ladder when the event signifying completion is thrown.

UILocalNotification - Later

In my application I am using UILocalNotification which works fine. But I need "Later" button in the alert instead of "Cancel". When the user clicks on the "Later" button I want to show the notification after sometime. Is that possible?
Thanks
No man, you are on the wrong way.Due to the limitations of iphoneSDK such thing is not possible.In local notification it will only show the two buttons in alert View.
1)Cancel
2)View
Still you can rename the View button to you wish:
localNotif.alertAction = #"Snooze";
rahter than renaming the Cancel button.

Adding multiple Dialog box to VC++ MFC application

I am currently working on a MFC GUI application, which does data manipulation based on user input. Now I would want to add a special feature so that only authorize user can able to write the data.
so as soon as a user click on Write button (void CMFC::OnWrite()), I wanted to open a new dialog box, which should ask for a password. the problem is I created a new Dialog box and on this even I called it with :
CPassWdDlg PassDlg;
if( PassDlg.DoModal() == IDOK )
{
AfxMessageBox("File Read Successfully");
}
else
return;
But, it just display the dialog box, and stuck there. In DoModel() call, I couldnt understand the reason of it.
Please let me know how to get away with it.
I think I found the reason, in the property page, I had disabled the dialog box, which is making it to not respond.

Resources