UPI (Unified Payment Interface) is a payment interface for Indian banks.
In UPI transactions are links. Just like bitcoin transactions are messages
Those links are passed to UPI payment apps and the payer has to login to the app and click the pay button.
Our app has to start an intent and pass link to the UPI payment app and after payer clicks the pay button we need to call onActivityResult.
I dont know anything about android development in java.
I use python kivy for android development. I want to know what should my onActivityResult should do.
Sample code :
UPI App Deep linking using Intent - inconsistent and buggy behavior
I can use java code in python using pyjnius.
Some reference link:
https://blog.deazzle.in/enable-upi-payments-in-your-app-without-the-need-to-integrate-with-a-bank-c911019f3b2d
you have not any need to do it manually. I have developed a library for it.
Just have to do a simple process.
final EasyUpiPayment easyUpiPayment = new EasyUpiPayment.Builder()
.with(this)
.setPayeeVpa("EXAMPLE#VPA")
.setPayeeName("PAYEE_NAME")
.setTransactionId("UNIQUE_TRANSACTION_ID")
.setTransactionRefId("UNIQUE_TRANSACTION_REF_ID")
.setDescription("DESCRIPTION_OR_SMALL_NOT")
.setAmount("AMOUNT_IN_DECIMAL_XX.XX")
.build();
easyUpiPayment.startPayment();
For more info, you can visit below site.
https://github.com/PatilShreyas/EasyUpiPayment-Android
Activity A:
Intent start = new Intent(MainActivity.this, PurchaseActivity.class);
startActivityForResult(start, 1);
And add this result listener:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
//payment was successful
}else if (resultCode == RESULT_CANCELED) {
//payment was canceled
}
}
}
And Activity B:
If payment was successful:
setResult(RESULT_OK, new Intent());
finish();
or if it was canceled:
setResult(RESULT_CANCELED, new Intent());
finish();
Related
How do i get the response from stripe with the new Activity Result Api? I create a new card and i want to attach it to a stripe account. To do that i have to use the confirm setup intent and wait for the answer from stripe. But how do i register this one with the new Api? This is my code and but the onActivityResult has been deprecated now. I know how to use it for picking images or making phone calls and other that can use the launch function of the register activity. I don't want to do this on the server side because if the card needs 3D secure webview stripe handles that automatically.
ConfirmSetupIntentParams confirmParams = ConfirmSetupIntentParams
.create(paymentMethodParams, clientSecret);
stripe.confirmSetupIntent(this, confirmParams);
#Override
public void onActivityResult(int requestCode, int resultCode, #org.jetbrains.annotations.Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
stripe.onSetupResult(requestCode, data, new ApiResultCallback<SetupIntentResult>() {
I found a tutorial online for creating a QR Code Scanner App for Android. It works great but the output of the scan is a toast notification as you can see in the code:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK) {
val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
if (result != null) {
if (result.contents == null) {
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show()
} else {
Toast.makeText(this, "Scanned: " + result.contents, Toast.LENGTH_LONG).show()
}
} else {
super.onActivityResult(requestCode, resultCode, data)
}
}
}
}
What i would like to do is for the scanned code to launch the url inside the app itself. As I want the pages to be hosted in the app itself, what i've done was create an actvity with the webview that loads the internal html page.
I took the scanner code and changed the positive outcome to open the webview activity :
startActivity(Intent(this, PagInfoActivity::class.java))
Which works fine. Anytime a QR Code is detected the app automatically loads the desired activity. I know this is not ideal, as the QR Code link itself is not being used to open the page, but what I was trying to do was to use that scan result on the webview load. I've created QRCodes with text strings instead of URLs so that i could inject them in the loadURL of the webview like this:
WebView.loadUrl("file:///android_asset/*QRCODE string*.html");
Is it possible to call result.contents from the MainActivity?
There are multiple ways you can achieve this. First option can be Explicit Intents
For Example,
You need to pass it as an extra:
Intent i = new Intent(this, PagInfoActivity.class);
i.putExtra("result", result.contents);
startActivity(i);
Then extract it from your PagInfoActivity like this:
Intent intent = getIntent();
String result= intent.getExtras().getString("result");
I logged in successfully and got the twitter access token and the twitter access secret using firebase-ui-auth [https://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md][1]:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN && resultCode == RESULT_OK) {
IdpResponse response = IdpResponse.fromResultIntent(data);
//twitter access token
response.getIdpToken();
//twitter access token secret
response.getIdpSecret();
}
}
I want to post on user's behalf(to their accounts, not to mine) using these two tokens that I will save on shared preferences.
1) Are these two tokens enough to post to user's account?
2) How do I do to post something using these two tokens?. I can't seem to find the proper docs for my particular case, the twitter api handling for android is really poor.
I already solved it myself by using fabric and its TweetComposer class.....
first you need to initialize fabric on the bootstrap Class of your app
Fabric.with(this, new Twitter(authConfig));
then on the class you want to make the tweet you get the firebase instance to get the logged in user and then you set the twitter consumer key and secret that you got when you log in to firebase UI https://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md, for future reference to get the two tokens needed to tweet on user's behalf you can do it like the link specifies:
To retrieve the ID token that the IDP returned, you can extract an IdpResponse from the result Intent.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
IdpResponse idpResponse = IdpResponse.fromResultIntent(data);
startActivity(new Intent(this, WelcomeBackActivity.class)
.putExtra("my_token", idpResponse.getIdpToken()));
}
}
Twitter also returns an AuthToken Secret which can be accessed with idpResponse.getIdpSecret().
and now you have everything you need:
mAuth = FirebaseAuth.getInstance();
if (mAuth.getCurrentUser() != null) {
// already signed in
twitter_consumer_key= preferences.getString("TWITTER_CONSUMER_KEY","");
twitter_consumer_secret= preferences.getString("TWITTER_CONSUMER_SECRET","");
TwitterAuthConfig authConfig = new TwitterAuthConfig(twitter_consumer_key, twitter_consumer_secret);
//setting up fabric
Fabric.with(this, new TwitterCore(authConfig), new TweetComposer());
}
and then let's say I want to tweet from a custom button onClick:
ImageButton tweetButton= (ImageButton) findViewById(R.id.tweet_button);
tweetButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
TweetComposer.Builder builder = new TweetComposer.Builder(mContext)
.text("just setting up my Fabric.");
builder.show();
}
});
the app will redirect you to the twitter app with the preseted message "just setting up my Fabric.". You can add pictures and videos too!
Hope that this helps someone in the future cause there is little info about fabric....
I am trying to send mail from my app.The problem is after successful/unsuccessful delivery of the email it doesn't return to the activity, meaning that onActivityResult() is not being called.
Here is my code:
String[] recipients = {"soham#gmail.com"};
Intent email = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
// prompts email clients only
email.setType("message/rfc822");
email.putExtra(Intent.EXTRA_EMAIL, recipients);
try{
// the user can choose the email client
startActivityForResult(Intent.createChooser(email, "Choose an email client from..."), 1);
}catch(android.content.ActivityNotFoundException ex){
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode == 1){
if(resultCode == RESULT_OK){
}else if (resultCode == RESULT_CANCELED){
}
}
}
I have checked this but not working for me. Can anyone tell me what am I doing wrong.
Edit
I got the problem.It will work fine in Activity.But it will not work on Fragment or FragmentActivity. All fragment is closing down forcefully.You can say my app is going on the background.How to solve this issue?Anybody got any idea.
If i uderstand your problem correctly;
In your activity's onActivityResult part you can find your fragment
YourFragment fragment = (YourFragment)getSupportFragmentManager().findFragmentById(R.id.your_framelayout_id);
And use your fragment's public method:
if(fragment != null)
{
fragment.yourPublicMethod();
}
In yourPublicMethod you can do whatever you want. I hope this helps you.
I am working on a java application which is in fact a back-office for my iOS application (iPhone and iPad)
I need to integrate TTS in my application in order to read mails content in english or french
I searched the net I found many tts engines such as festival or freeTTS but the problem that It doesn't support french
Is there any other TTS engines (free or commercial) that I can integrate in my application???
private TextToSpeech mTts;
protected void onActivityResult
( int requestCode, int resultCode, Intent data)
{
if (requestCode == MY_DATA_CHECK_CODE)
{
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
{
// success, create the TTS instance
mTts = new TextToSpeech(this, this);
}
else
{
// missing data, install it
Intent installIntent = new Intent();
installIntent.setAction( TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
}
}
}
mTts.isLanguageAvailable(Locale.FRANCE))
click this link FREETTSenter link description here
STACKOVERFLOW already described similar to this questionenter link description here