Android pop up spinning loader - android

I'm creating an android app where user loads some data from an online server when he hits a button
I need to add the following :
when user hits the button a pop-up screen shows on top of current screen & shows something like
"loading" "spinning loader" or anything like this
any thoughts ?

Have a look at this Android Developer page at the section "Creating a ProgressDialog". Android offers such a dialog out of the box.

You can try a function like showProgressDialog(Activity activity)with this context:
if ((mySpinnerDialog== null) || (!mySpinnerDialog.isShowing())) {
mySpinnerDialog= new Dialog(activity);
mySpinnerDialog.getWindow().getCurrentFocus();
mySpinnerDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mySpinnerDialog.setContentView(R.layout.some_layout);
mySpinnerDialog.setCancelable(false);
mySpinnerDialog.setOwnerActivity(activity);
mySpinnerDialog.show();
} else {
mySpinnerDialog.setOwnerActivity(activity);
}
and dismiss this with mySpinnerDialog.dismiss();. Handle Illegalargumentexception on dismiss()

Related

Android UI testing: how to click to Android dialog?

Problem:
I cannot run test, because when Activity using fullscreen mode, Android dialog (see picture) is showed.
Goal:
I want to click to GOT IT and close the dialog.
Code (Kotlin):
//device is instance of UiDevice UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val gotIt = device.findObject(UiSelector()
//.clickable(true)
//.checkable(false)
//.className("android.widget.Button")
//.packageName("com.android.launcher3")
//.resourceId("android:id/ok")
//.index(3) //by index for language-independent
.text("GOT IT")
)
if (gotIt.waitForExists(3000)) {
try {
return gotIt.click()
} catch (e: UiObjectNotFoundException) {
e.printStackTrace()
}
} else Log.i(TAG, "clickViewingFullscreenDialog: btn not exists")
I tried many combination of selectors, but i still cannot click to GOT IT. Selectors are correct, but dialog is as "invisible" or unfocusable. Cannot click to dialog.
Additional info:
Trying on Emulator Nexus 5 Android 7.0.
I tried uiautomatorviewer and layoutinspector to get information about View hierarchy to find this Android Dialog, but i can get information only about android home screen (see second picture), not about own Activity (first picture).
is "GOT IT" a positive or neutral button?
if it's positive, click on ID android.R.id.button2.
And in case it's neutral button, click on ID android.R.id.button3

android- How to prevent enter key/click coming from barcode scanner

Hello I have an application which I got entries by barcode scanner. I use Zebra TC56 as testing device.
I need to show a warning message to the user and that is why I have a custom dialog box.
Dialog box is being showed when user gets an error. Picture of my dialog box can be seen here :
Below red part is a button and when button is clicked , dialog box will be closed and user will turn the latest screen.
Everything works fine but there is somethin I dont want. When user scans a barcode(enters data) button is trigered and dialog box is closed.
I want dialog box to be closed only by clicking the button(TAMAM) from the screen. But when I scan anything, dialog box is closed.
Here is the code of the dialog box class :
public class ViewDialog {
public void showDialog(Activity activity, String msg){
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.customdialog);
TextView text = (TextView) dialog.findViewById(R.id.text_dialog);
text.setText(msg);
Button dialogButton = (Button) dialog.findViewById(R.id.btn_dialog);
dialogButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
}
I tried to get focus to somewhere except the button(TAMAM) but it didnt help. If someone knows how to dismiss enter key from the barcode scanner, I really need some help and will be appreciated. (I already set the device to send Enter key because I need in other screens)
Few ways to do this that I can think of.
Firstly, I presume you are using DataWedge to automatically append the enter key to scanned data, you could dynamically switch to a profile which did not send the enter key but was identical in every other way using the SWITCH_PROFILE API: http://techdocs.zebra.com/datawedge/6-3/guide/api/switchtoprofile/. This is presuming that you still need to be able to scan when the dialog is visible, if you wish to disable scanning entirely you could use the SCANNER_INPUT_PLUGIN API: http://techdocs.zebra.com/datawedge/6-3/guide/api/scannerinputplugin/.
Secondly, you could use the EMDK profile API to change the parameters of the KeyStroke output plugin (http://techdocs.zebra.com/emdk-for-android/6-3/mx/data-capture/keystroke/#keystrokeoutput) then apply that newly modified profile. I've never tried that myself but it should work - check out the following sample for the principles behind that: http://techdocs.zebra.com/emdk-for-android/6-3/samples/data-capture/
Thirdly, you could use the Java SDK for the scanner which gives you more control over how the scanner behaves (http://techdocs.zebra.com/emdk-for-android/6-3/api/)

How to display rolling updates on Android and iOS

I have a requirement to display the different stages of a Process in a dialog box overlay on the mobile app such as "Process 1 started" "Process 1 completed" "Process 2 started" and so on until the process is completed.
Essentially, what I'm looking for is scrollable text in an overlay screen appearing as the app receives different notifications(BLE characteristics). No user interaction required. Is there an out-of-the-box dialog box control that I can use? Any other suggestions for such a display?
U can add the DialogFragment and
if(process1.isDone())
{
informationOnDialogFragment
}
if(process2.isDone())
...
But the easiest way is add ProgressDialog
U can set message to ProgressDialog
You can achieve it using simple toast or other innovative libraries like:
1. EFInternetIndicator
2. FTIndicator
You can use Progress Dialog . With progress.setCancelable(false); you can make it so the user can`t navigate away from the dialog.

How to create pop up in phone gap

Helo,
Is there a possibility to click on button and show a popupover and inside it there is two buttons. When i click on each of them , i have an alert.
If there isn't a possibility with a popupover is there a possibilty of any other popup window?
My Android application is developped in phonegap
Thanks a lot
Take a look at the cordova dialogue api.
https://github.com/apache/cordova-plugin-dialogs/blob/master/doc/index.md
I think you are looking for the navigator.notification.confirm feature.
Using this feature you can display a popup with multiple options for the user to tap on.
The index of the button the user taps on is returned to the confirmCallback, so you can handle the user input.
navigator.notification.confirm(message, onConfirm, [button1], [button2]);
function onConfirm(buttonIndex) {
alert('You selected button ' + buttonIndex);
}
perform operations based on buttonIndex.

Mono Droid Modal Popup

I am wondering how I go about (if it is possible) creating a modal popup in a mono for droid application.
Scenario: The application talks to the customers hosted web server (so this location will be different customer to customer). To use the app the user must specify the connection string of their web server. So when the application starts and it hits the main activity, the first task I do is check if there is a connection string set in the devices application settings. If not I want to throw up a simple modal popup that allows the user to specify a connection to their server.
I dont really want to start a normal activity because the user will be able to click the back button and just go back to the main menu and the app is than in an invalid state because it doesnt know what server to talk to.
Any ideas on how I go about this?
Or should I be structuring the activity chain so that the connection string is entered on the first activity so that if they click back it actually goes out of the app?
Im a little confused.
Thanks in advance
This is possible with AlertDialog. It can create dialogs for simple input with lists, checkboxes, yes/no buttons and custom views.
There is a sample in the Xamarin Sample Repository for different type of dialogs and in the bottom you can find one where a custom view with a username and password field has been added.
So first define your custom view you want to put in the AlertDialog. alert_dialog_connection_entry.xml and is a Layout:
Somewhere in your activity add the code:
var connection_string_view = LayoutInflater.Inflate(Resource.Layout.alert_dialog_connection_entry, null);
var builder = new AlertDialog.Builder(this);
builder.SetTitle("Connection String");
builder.SetView(connection_string_view);
builder.SetPositiveButton("OK", OkClicked);
builder.SetNegativeButton("Cancel", CancelClicked);
builder.Create();
builder.Show();
Add some handlers for the buttons:
private void CancelClicked(object sender, DialogClickEventArgs dialogClickEventArgs)
{
//Todo
}
private void OkClicked(object sender, DialogClickEventArgs dialogClickEventArgs)
{
var dialog = sender as AlertDialog;
if (null != dialog)
{
var connectionEdit = dialog.FindViewById(Resource.Id.connectionstring_edit) as EditText;
if (null != connectionEdit)
Console.WriteLine("Connection String: {0}", connectionEdit.Text);
}
}
That should be it. You should be able to put any kind of custom view in the dialog.
If you just want to display a modal popup for letting users put their connection string, you could try this.
First, you need to have a simple layout for how the dialog is presented. In this case, a TextView displaying something like "Connection string:" and an EditText to let the user put connection string is probably enough to go.
Then, you can put this code somewhere in your MainActivity, like after checking application settings or something similar.
var builder = new AlertDialog.Builder(this);
var view = LayoutInflater.Inflate(Resource.Layout.ModalDialog, null);
builder.SetView(view);
string connectionString = view.FindViewById<EditText>(Resource.Id.ConnectionString).Text;
AlertDialog alert = builder.Create();
alert.SetCancelable(false); //This prevents the dialog from being dismissed by either hit back button or hit out side of the dialog
alert.SetButton("OK", (s,e)=> ToDo(connectionString)); //Now you have the connection string, to do whatever you want.
alert.Show();
As you said, the alternative could be allowing user specify the connection string in the first screen. This is a good approach too. I assume you know how to do it, so I didn't post code here.

Categories

Resources