onGoing notification can still be removed by user, manually - android-notifications

i create an application and i want after click on specific button, a "Permanent Nofitication" show on notification bar.
i search for it and use these codes:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_clip_board_service)
.setContentTitle(getResources().getString(R.string.notifTitle))
.setContentText(getResources().getString(R.string.notifText))
.setOngoing(true);
the ongoing method, prevent user to manually clear the notification.in my emulator(genymotion), everything is ok.but in my real Phone(Huawei G8) when i try to remove notificaiton, a pop-up menu appeared and say:
Not Recomended
removing ongoing notification may affect app stability.
the menu has already two buttons:cancel and Remove.and i can remove the notification.:(
i don't want user manually remove notification.
is the problem about my Phone or setOngoing(true) method?
thanks in advance...

Based off what I'm seeing for my app that behaves similarly, it appear Huawei phone's always allow clearing notifications and shutting down the app. My app even runs as a device administrator and it can still be cleared.

Related

Telegram Web Apps method Expand isn't working

I found that the method Expand of window.Telegram.WebApp object isn't working in the Telegram client for Windows and IOS on computers and tablets.
How to increase the size of Web Apps frame for those devices?
function buttonOn(){
// do something on btn click
}
let main_page = document.querySelector('#main_page');
if (main_page){
window.Telegram.WebApp.expand() //expand window after page loading
window.Telegram.WebApp.MainButton.onClick(buttonOn) //set func on main button click
window.Telegram.WebApp.MainButton.setParams({'text': 'Корзина'}) // set byn params
window.Telegram.WebApp.MainButton.show() //show telegram btn
}
Other button events
Remove the line from the function:
window.Telegram.WebApp.expand() //expand window after page loading
And call it in the beginning/at the top of your main javascript code. (The code that will start running once the user has clicked on the button)
Also, you can make your code a lot shorter by putting window.Telegram.WebApp in a variable like:
const tele = window.Telegram.WebApp; //Initializes the TELEGRAM BOT and
//Gets the user's Telegram ID from the Telegram API
tele.expand(); //Expands the app on the users' phone to 100% height
The reason is, probably, you are a bit incorrect in understanding what "expansion" is. This term could only be applied to mobile devices with OS such as Android or iOS. Web App is displayed there in such native component as BottomSheet with inserted WebView containing your web application. Initially, in mobile devices, application is being opened minimized (not expanded). To make it use maximum allowed height of screen, you could call expand() method. It must work through window.Telegram.WebApp.expand().
In desktop or web versions of Telegram, Web App is displayed in separate component which is not allowed to change its size.
You could probably find more useful information about viewport and expansion here, or use alternative libraries, such as twa-bridge or twa-sdk

Is it possible to use a xamarin form in place of a winform on a local display?

I have a number of console application that use winforms to gather simple input from the user (Do this and click "OK", Did this happen click "Yes" or "No" That kind of thing) There is a new requirement that we provide the option to gather the simple input from the user on a handheld device that runs Android.
I had hoped to convert our winforms to Xamarin forms that could be used either locally or be sent to the handheld device. This is not my area, really, so it may be that I am not looking at the problem in the right way.
The system running the console application is usually a laptop or maybe a desktop.
Does anyone have any advice?
You can use App Center Analytics Events Metrics to track user event.
Here is the document for Xamarin:
You can track your own custom events with up to twenty properties to
understand the interaction between your users and the app.
Analytics.TrackEvent("Video clicked", new Dictionary<string, string> {
{ "Category", "Music" },
{ "FileName", "favorite.avi"}
});

Azure AD (ADAL) Login Screen Loses Entered User Email on Device Orientation in Android Only-XamarinForms.Android

I have Xamarin.Forms application that authenticates user against Azure AAD using ADAL (Microsoft.IdentityModel.Clients.ActiveDirectory). That all works fine but on Android, device orientation looses user email on the Microsoft authentication screen.
Here I am in Portrait mode and I have entered user email:
Clicking on Next lands on screen asking to enter password. If I now rotate device on Android, it will return me back to blank screen above, user email I entered above is lost:
Device rotation should not return user back and re-prompt for user email again. It should stay on password prompt.
How do I prevent the rotation from re-prompting for user email? I dont want to disable rotation, I just want to prevent it from returning me back to screen that prompts for user email again.
This is Xamarin.Forms application and my MainActivity has already ConfigChages.Orientation attribute like below; however, this is not solving the issue:
[Activity(Name = "my.mainactivity"
, Label = "MyApp"
, Icon = "#drawable/icon"
, ConfigurationChanges = ConfigChanges.ScreenSize
| ConfigChanges.SmallestScreenSize
| ConfigChanges.ScreenLayout
| ConfigChanges.Orientation)]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
...
}
UPDATE
Even if I freeze orientation to Portrait before call to AcquireTokenAsync and unfreeze it after the call receives response, it still behaves same - it will still rotate the Microsoft sign in page even though I freeze its parent (MainActivity) to Portrait (which is the owner passed in PlatformParameters to the call to AcquireTokenAsync. So, my activity stays in portrait but that sign-in page still rotates and looses data. It appears that the WebView Microsoft uses internally in AcquireTokenAsync is not following orientation settings on the activity passed inside PlatformParameters to AcquireTokenAsync.
Confirmed by Microsoft that this is their internal issues. If you are also running into this issue on Android where device rotation returns you back to prompt for user email, you can follow up progress of fixes for both ADAL and MSAL here:
https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/1622 https://github.com/xamarin/xamarin-android/issues/3326
I use Entry at my side, adding ConfigurationChanges = ConfigChanges.ScreenSize| ConfigChanges.Orientation, it works fine.
If you still have this issue, I suggest you can follow the next steps:
1.on Forms PCL, you can override OnSizeAllocated to check screen orientation, like this:
How to detect screen orientation of the device in Xamarin.Forms?
2.On Forms PCL and Android, you can use MessageCener to subscribe and send data
3.override method onSaveInstanceState() and onRestoreInstanceState(), like this:
Handle screen rotation without losing data - Android
The issue has been fixed in ADAL Release 5.1.1, and will be included in the next version of MSAL (most likely 4.3.1).
This issue is caused by Microsoft's ADAL component Microsoft.IdentityModel.Clients.ActiveDirectory and it has been fixed in 5.1.0 version released just couple of weeks ago (current version is 5.2.0).
What I had to do in order to fix this issue is:
1. Update ADAL from 3.19.8 to 5.2.0 (everything below 5.1.0 has this problem)
2. Then modified AuthorityURL passed to AuthenticationContext c-tor from something like https://login.microsoftonline.com/my-tenant-id/oauth2/authorize to https://login.microsoftonline.com/my-tenant-id
Number 2 was necessary even though Microsoft claims in most places that the change is non-breaking change (they confirmed this is necessary).
After this, I was able to authenticate just like before but rotation on Android would not loose already provided user id and/or password.

FirebaseUI for Web — Auth - how to re-authenticate?

I'm using FirebaseUI for Web — Auth widget to simplify the auth workflow, and I'm stuck with a problem. Everything works OK the first time. But, after I sign in, the widget contents clears away, and the 'Sign in with ...' buttons never come back. Trying to recreate the widget brings up the error "UI Widget is already initialized on the page. Only one widget instance can be initialized per page."
This means that users need to refresh the page to get the sign-in buttons back. Is there a more elegant way?
Are you rendering the widget in a single page application? If so, this currently won't work. You will have to render the sign in widget in a popup whenever you want the user to sign in.
As bojeil stated in the first answer (May 2016), there was really a problem using it in single page applications workflows. But in more recent versions of firebase-ui you can actually reset the widget so you won't need to initialize it again.
All you need to do is to keep the widgets instance reference in a variable. Then, when you want to render it again you use the same reference, reset it and then restart it.
var ui;
if (ui) {
ui.reset();
} else {
ui = new firebaseui.auth.AuthUI(firebase.auth());
}
ui.start('#firebaseui-auth-container', uiConfig);

Android Dialog dismiss using handler

I meet a stranger question,when I read the android GlobalAction source code,I find that it will start a dialog,but it add a judgement which will judge whether this dialog has been shown,if it was shown before,it will be dismissed and then show it.The stranger things is that it dismiss the dialog,than use Handler to send a message to create and show dialog again,I can't understand why it needs to send a handler message,I think it just calls dialog dismiss function.then calls show function,it no problem.The comment said:"Show delayed, so that the dismiss of the previous dialog completes",but I also can't understand the meaning,please someone help me explain it,Thanks a lot.
if (mDialog != null) {
mDialog.dismiss();
mDialog = null;
// Show delayed, so that the dismiss of the previous dialog completes
mHandler.sendEmptyMessage(MESSAGE_SHOW);
}
Many Android UI functions are themselves implemented using messages, and so do not complete immediately. When you call Dialog.dismiss(), Android queues a message that does the actual dismissing. The author of this code wants to ensure the dialog is actually dismissed before showing it again, and so she posts her own message, which will not run until after the one posted by Android.

Resources