How to confirm setup intent for stripe in a Fragment? - java

how can i confirm a setup intent for stripe in a Fragment now that onActivityResult has been deprecated and replaced with activity result launcher? How do you pass that to stripe? Where do i need to add stripe.onSetupResult?
ConfirmSetupIntentParams confirmParams = ConfirmSetupIntentParams
.create(paymentMethodParams, clientSecret);
stripe.confirmSetupIntent(this, confirmParams);

Stripe has revised the docs regarding Android development to use the newer launcher methods. This appears to be a large enough change that it’s not as simple as changing one function call for another. Take a look at the new docs here:
https://stripe.com/docs/payments/save-and-reuse?platform=android&ui=payment-sheet#android-collect-payment-details
The change to the SDK is pretty significant. In order to dig into the changes try reviewing the this PR.
https://github.com/stripe/stripe-android/commit/8b77ca2487a01f786cf845e5f644b98460036708
When I look at the StripeIntentActivity.kt I can see on line 160 they revised the stripe.confirmSetupIntent to use paymentLauncher.confirm instead. I think the code changes there might help you figure out how to reconfigure your Fragment.

Related

How to get a web page source code with GeckoView

I am an android developer and I knew about GeckoView recently.
I can get source code of a web page by android WebView (java code).
However with my new website, android Webview can't load the webpage but GeckoView can.
Now I want to get source code of a web page by GeckoView.
Is there any body know the solution to resolve this problem ?
Thank in advance
As far as I know, you cannot use GeckoView to get the source code, but the geckoview library does have GeckoWebExecutor. Take a look at the fetch method and the WebResponse it returns.
By converting the WebResponse.body InputStream to a String you can get the source code.
One option for doing this could follow these steps:
detect which page my geckoview loaded;
save the loaded url into a sharedpref;
if user wants to see the source of the page, load the url saved within that sharedpref.
So...
(1-2) as you already know, geckoview doesn't have that handy shouldOverrideUrlLoading() method, so you will have to deal with the NavigationDelegate class, which has the onLocationChange(), where i put this line, which does nothing more than save the current url as a string into a sharedpref string named "geckoViewUrl":
sharedprefs.edit().putString("geckoViewUrl", url).apply();
having all setup before (sharedprefs etc). Detected the loaded page and saved the url into a sharedpref, let's go to the final step 3.
(3) for my use, wishing only to allow the user to see (and copy) the source, for the law of the minimum effort i used another activity with a plain and old webview to display it. This is very easy to implement and rises no confusion to the user. He/She wants to see the code, i show it in another activity. When it's done, he/she closes the new activity and life continues.
So, user wants source? Load another activity with a webview and make it load that saved sharedpref string:
addr2open = pref_out.getString("geckoViewUrl", "");
Doing this (for example), you get the url user wants to see source assigned to a string var. To finish, all you have to do is to make the webview load this string preceded by the precious word view-source:, this way:
webView.loadUrl("view-source:" + addr2open);
That's it. Of course you could implement a solution relying on the same activity, or using geckoView, showing multiple options, menus etc. I only wanted to show you a way to solve your problem in a nice 'n' easy way. You asked for "How to get a web page source code with GeckoView". Here is the answer. Works perfectly. If this is good for you, please, accept this as the correct answer. Thank you. Happy coding.
One example on the use of "view-source", from the creators of GeckoView: https://firefox-source-docs.mozilla.org/devtools-user/view_source/index.html (see item "Link to a line number").

Get Intent information

In a app I bought that is written in Java for Android, I have one line of code that is:
data_trip = (HashMap<String, String>) getIntent().getSerializableExtra("TRIP_DATA");
And data_trip variable is filled with a lot of data that is stored in a database in a server. Now I added a field in that database, and is not automatically get. If I do data_trip.get("new_field") I get and error. So somewhere it must be a explicit sql query for doing this. I tried debugging and follow step by step but I can't get anything. The only clue is that line. So, how can I access to that intent and "TRIP_DATA" thing? Im lost.
You would have to start by finding where the Intent is set for that Activity. After you've found that you can likely find the code that is associated with creating that intent. The SerializableExtra is similar to setting Arguments for a Fragment so I'm willing to bet that if you find where the SerializableExtras are set at you can figure out what to add/remove to fix your issue.
Feel free to let me know if you have any further issues or what I have suggested doesn't work

Vaadin - pass data to different UI

I am new to Vaadin and I tried to find the answer to this by searching SO as well as Google so any help will be appreciated or at least point me in the right direction.
My app navigates from one view to another using the following logic
ActivitiesUI startUpActivity = new ActivitiesUI();
UI.getCurrent().setContent(startUpActivity.buildMainArea());
I need to know how I can pass data (like a String or an int) from the current UI to the one being navigated to (in this case startUpActivity)
Coming from an Android background, I am thinking along the lines of an Intent
After some digging into the Wiki, I ended up using the Http Session to set and get the variables and it is working fine.

Trasparent intro overlay to introduce user the app

I was wondering to create something like a setup wizard for when the user first starts my app. This is needed due to the complexity of the app to help the user. Searching for something like this I found a library that isn't a setup wizard, but lets you point an element on the screen and give some info about it.
The library is this link. (Showcase View Library by Espin)
I'm able to show one indication using this, but I can't concatenate more than one indication, you know, the first is shown, you pulse next and goes to the nex indication, this way until you arrive to the end and pulse finish.
Looking for any tutorial or step-by-step guide that could help me doing this, I found one, but it was done with old code, and the newest version of the library has some changes that doesn't fit the example. I've tried modifiying the code of this example to match with the new version of the library, but I don't get to view the indication one by one, I just get all them overlapped.
This is the link to the library's ShowcaseView class where all this logic is defined: ShowcaseView.java
And this is how the doc says to implement it ot your app:
new ShowcaseView.Builder(this)
.setTarget(new ActionViewTarget(this, ActionViewTarget.Type.HOME))
.setContentTitle("ShowcaseView")
.setContentText("This is highlighting the Home button")
.hideOnTouchOutside()
.build();
Has someone worked with this library and knows how could I concatenate few indications?
What's missing in v5
ShowcaseViews: the class which queues up ShowcaseViews in a
tutorial-type method. I never really liked this class (generally, you
should use SCV sparingly); I'll add it back in based on the Builder
class when I can.
So either:
implement it by yourself and submit a pull request.
Or wait for the next release.
Or use v4
Or submit an issue on github to directly ask the author when this will be released.

android Speech recognition API.System always recognizes default language

Here is how my code looks.
//loc will be either "ru-RU" or "en-US"
speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, loc);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, loc);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, loc);
Problem is that, when I am using the program with different phones it works well.But with my cell phone it always chooses default language. And rare times it is just mixing recognition languages. Like half of the result is in one language other half in another language.
I dont know whether it is cause of system or from code itself?
Plus It worked well before on my phone too. Can it be cause of some settings?
How can I overcome and fix it? I need to know to inform users how to fix it if they will have the same problem
How can I use voice recognition with other languages android
SpeechRecognizer with Google Search version 3.6.14.1337016 can't recognize other voice language except default
Firstly, the problem exists while using SpeechRecognizer
On this case only solution was to delete google search cause it is related to google search update. Doing so we will delete all updates. This worked on my own device
But on my opinion,actually, small updates should not change api behaviour. I hope there is programmatic way to solve this issue or there will be new update that will fix it
Here is undocumented programmatic solve:
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new
String[]{});
it is artetxem's answer
Other solution is just to call activity for recognition. This way google's dialog activity will be seen but there will be no language problems.
Issue opened by me issue
Issue opened on google search by artetxem issue
Hi #VSL i was also facing same problem to set language hindi instead of english, but Speech recognizer always take my Android OS default language which is english. But below code solved my problem
Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "hi");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, InteractionActivity.this.getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
speech.startListening(recognizerIntent);

Categories

Resources