how to hide USE FALLBACK in Plugin.Fingerprint dialogue - xamarin.forms

i have implemented finger-touch login using Plugin.Fingerprint Pluginin my xamarin application.
i dont want to show USE FALLBACK option in dialogue.
i have tried this way to hide it
var config = new AuthenticationRequestConfiguration("pput your finger to authenticate!")
{
FallbackTitle = string.Empty
};
var auth = await CrossFingerprint.Current.AuthenticateAsync(config);
but it is still showing.
anyone have idea how can i hide that?
please help .

On android platform, if you want to disable it, you can inherit from FingerprintDialogFragment and override OnCreateView.
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = base.OnCreateView(inflater, container, savedInstanceState);
view.FindViewById<Button>(Resource.Id.fingerprint_btnFallback).Visibility = ViewStates.Gone;
return view;
}
In your MainApplication class, override OnCreate
public override void OnCreate()
{
base.OnCreate();
RegisterActivityLifecycleCallbacks(this);
//A great place to initialize Xamarin.Insights and Dependency Services!
CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
CrossFingerprint.SetDialogFragmentType<MyCustomDialogFragment>();
}

Related

How to hide voice search icon in searchfragment using android Tv

How to hide Voice search icon in android firetv extends android.support.v17.leanback.app.SearchFragment library. its coming default in my code when i extended that search library... For now i dont want to use voice search functionality...
Below listener is coming default :::
setSpeechRecognitionCallback(new SpeechRecognitionCallback() {
#Override
public void recognizeSpeech() {
Log.v(TAG, "recognizeSpeech");
try {
Intent mSpeechRecognizerIntent = getRecognizerIntent();
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, new Long(3000));
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, new Long(2000));
startActivityForResult(mSpeechRecognizerIntent, REQUEST_SPEECH);
//startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Cannot find activity for speech recognizer", e);
}
}
});
Here is how you can hide the voice search in searchFragment .
Inside the searchFragment you need to Override the onCreateView.
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = super.onCreateView(inflater, container, savedInstanceState);
FrameLayout searchFrame = root.findViewById(R.id.lb_search_frame);
SearchBar mSearchBar = searchFrame.findViewById(R.id.lb_search_bar);
SpeechOrbView mSpeechOrbView = mSearchBar.findViewById(R.id.lb_search_bar_speech_orb);
if (mSpeechOrbView != null) {
mSpeechOrbView.setOrbIcon(ContextCompat.getDrawable(getActivity(),
R.drawable.ic_search_sel));
mSpeechOrbView.setVisibility(View.GONE);
}return root;}
Do this it will work. Happy Coding :)
Based from this link, Google has default voice search. If you do not supply a callback via setSpeechRecognitionCallback(SpeechRecognitionCallback), an internal speech recognizer will be used for which your application will need to request android.permission.RECORD_AUDIO.
So you need to do either
Implement setSpeechRecognitionCallback
Request android.permission.RECORD_AUDIO on AndroidManifest.xml
Old question but finally added to the Leanback library:
Made speech recognizer optional for SearchSupportFragment
https://developer.android.com/jetpack/androidx/releases/leanback?hl=nb#1.1.0-rc01

Can't get image from native gallery

I've created a test app to understand how to call the native gallery, select an image and display it on an imageView.
1st test
I had a simple setup. One activity and a fragment(residing within that activity) that has a button(calls gallery intent) and an imageView for the selected image. This worked perfectly.
2nd test
Changed the setup a bit by adding another activity and a tab host to the main activity. This new empty activity would be the launching activity and it's only purpose was to switch to the main activity that holds the fragment that calls the gallery intent. Everything works fine until I select the image from the gallery. Once the image is selected, it doesn't go back to the my test app. It's like a weird soft crash. Logcat doesn't display any errors so it's a bit hard to troubleshoot. I also placed a breakpoint on each line of the OnActivityResult override but they never hit.
I was hoping somebody would shed light on this matter.
SDK version is 23 and build tools is 23.0.3
Heres what I got so far:
Main2Activity(Launching activity)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
ActivityConfig.CreateActivity(MainActivity.class, this, true);
}
In case you were wondering what CreateActivity does:
public static void CreateActivity(Class activityClass, Context context,
boolean finishPreviousActivity)
{
Intent intent = new Intent(context, activityClass);
if (finishPreviousActivity)
{
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
}
context.startActivity(intent);
}
MainActivity(I only use the third position on the tabhost. That's where the fragment is)
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
tabHost.setup();
tabHost.addTab(Tabs.CreateTab("T1", R.id.tabFrag2, tabHost));
tabHost.addTab(Tabs.CreateTab("T2", R.id.tabFrag3, tabHost));
tabHost.addTab(Tabs.CreateTab("T3", R.id.tabFrag, tabHost));
tabHost.setCurrentTab(2);
}
Fragment
private ImageView imageView;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_blank, container, false);
Button button = (Button)view.findViewById(R.id.Btn);
imageView = (ImageView)view.findViewById(R.id.Img);
button.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(intent, 100);
}
});
return view;
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100)
imageView.setImageURI(data.getData());
}
After much trail an error I noticed that after selecting an image it was going back to the launching activity, but not through onCreate or it's overridden onActivityResult. It was going through onResult. My conclusion was redesign the whole interface in a way that only one activity was required

How to I use a getLoaderManager().initLoader(0, null, getActivity()); using fragment? - ...implements LoaderManager.LoaderCallbacks<Cursor>

Please, I tried a lot but no solution so far.
This is what I want and I have implemented the LoaderManager already but nothing and below is my only error
getLoaderManager().initLoader(0, null, **getActivity()**);
I'm not sure if you could use this.. But it seems to work for me.
Within the Fragment.java file,
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.YOUR_LAYOUT_ACTIVITY_XML_FILE, container, false);
// Your other codes here.... like setting up of adapters and all
LoaderManager loaderManager = getActivity().getLoaderManager(); // Seems like within the Fragment files, `getActivity()` will reference the original activity.
loaderManager.initLoader(CARPARK_LOADER_ID, null, this);
return rootView;
in what class you did this? what your class implements? what LoaderManager you imported in your class(android.app or android.support.v)?

getFragmentManager() returns null, with android.support.v4.app.DialogFragment support libraray

here is the fragment dialog:
import android.support.v4.app.DialogFragment;
public static class SensorMeasurmentsDialogFragment extends DialogFragment {
public static SensorMeasurmentsDialogFragment newInstance(int title) {
SensorMeasurmentsDialogFragment frag = new SensorMeasurmentsDialogFragment();
Bundle args = new Bundle();
args.putInt("title", title);
frag.setArguments(args);
return frag;
#Override public Dialog onCreateDialog(Bundle savedInstanceState) {
.....
}
}
}
the call to it is done from a regular activity not from a fragmentActivity because
my activity already extends mapActivity.
m_measurmentDlg=SensorMeasurmentsDialogFragment.newInstance(R.string.app_name);
m_measurmentDlg.show(m_measurmentDlg.getFragmentManager(),"measurments");
any idea why is it Null?
In one of my fragments, I was using replace so when I used add it worked good!
might help you
The activity must extend from FragmentActivity for you to be able to use Fragments. You might have to use a workaround at the moment until Google updates their map library.
You might have to use a modified compatibility lib such as this one:
https://github.com/petedoyle/android-support-v4-googlemaps
I ran into this problem also. The problem happens with setRetainInstance(true) only. My workaround is to use the parent activity's FragmentManager object instead of the DialogFragment's FragmentManager.

commit fragment from onLoadFinished within activity

I have an activity which loads a data list from the server using loader callbacks. I have to list out the data into a fragment which extends
SherlockListFragment
i tried to commit the fragment using
Fragment newFragment = CategoryFragment.newInstance(mStackLevel,categoryList);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.simple_fragment, newFragment).commit();
in onLoadFinished and it gives an IllegalStateException saying
java.lang.IllegalStateException: Can not perform this action inside of onLoadFinished
I have referred the example in actionbar sherlock, but those examples have loaders within the fragments and not the activity.
Can anybody help me with this o that I can fix it without calling the loader from the fragment!
Atlast, I have found a solution to this problem. Create a handle setting an empty message and call that handler onLoadFinished(). The code is similar to this.
#Override
public void onLoadFinished(Loader<List<Station>> arg0, List<Station> arg1) {
// do other actions
handler.sendEmptyMessage(2);
}
In the handler,
private Handler handler = new Handler() { // handler for commiting fragment after data is loaded
#Override
public void handleMessage(Message msg) {
if(msg.what == 2) {
Log.d(TAG, "onload finished : handler called. setting the fragment.");
// commit the fragment
}
}
};
The number of fragments depend on the requirement.
This method can be mainly used in case of stackFragments, where all fragments have different related functions.
As per the Android docs on the onLoadFinished() method:
Note that normally an application is not allowed to commit fragment transactions while in this call, since it can happen after an activity's state is saved. See FragmentManager.openTransaction() for further discussion on this.
https://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks.html#onLoadFinished(android.content.Loader, D)
(Note: copy/paste that link into your browser... StackOverflow is not handling it well..)
So you simply should never load a fragment in that state. If you really don't want to put the Loader in the Fragment, then you need to initialize the fragment in your onCreate() method of the Activity, and then when onLoadFinished occurs, simply call a method on your fragment.
Some rough pseudo code follows:
public class DummyFragment {
public void setData(Object someObject) {
//do stuff
}
public class DummyActivity extends LoaderCallbacks<Object> {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fragment newFragment = DummyFragment.newInstance();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.simple_fragment, newFragment).commit();
getSupportLoaderManager.initLoader(0, null, this)
}
// put your other LoaderCallbacks here... onCreateLoader() and onLoaderReset()
public void onLoadFinished(Loader<Object> loader, Object result) {
Fragment f = getSupportLoaderManager.findFragmentById(R.id.simple_fragment);
f.setData(result);
}
Obviously, you'd want to use the right object.. and the right loader, and probably define a useful setData() method to update your fragment. But hopefully this will point you in the right direction.
As #kwazi answered this is a bad user experience to call FragmentTransition.commit() from onLoadFinished(). I have found a solution for this event by using ProgressDialog.
First created ProgressDialog.setOnDismissListener(new listener) for watching the onLoadFinished().
Further i do progressDialog.show() before getLoaderManager().restartLoader().
And eventually place progressDialog.dismiss() in onLoadFinished().
Such approach allow do not bind main UI thread and Loader's thread.
public class FrPersonsListAnswer extends Fragment
implements
LoaderCallbacks<Cursor>{
private ProgressDialog progressDialog;
#Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_persons_list, container, false);
//prepare progress Dialog
progressDialog = new ProgressDialog(curActivity);
progressDialog.setMessage("Wait...");
progressDialog.setIndeterminate(true);
progressDialog.setOnDismissListener(new OnDismissListener() {
#Override
public void onDismiss(DialogInterface dialog) {
//make FragmentTransaction.commit() here;
//but it's recommended to pass control to your Activity
//via an Interface and manage fragments there.
}
});
lv = (ListView) view.findViewById(R.id.lv_out1);
lv.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, final View view,
final int position, long id) {
//START PROGRESS DIALOG HERE
progressDialog.show();
Cursor c = (Cursor) parent.getAdapter().getItem(position);
// create Loader
getLoaderManager().restartLoader(1, null, curFragment);
}
});
return view;
}
#Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
switch (loader.getId()) {
case 1:
//dismiss dialog and call progressDialog.onDismiss() listener
progressDialog.dismiss();
break;
default:
break;
}
}

Resources