简体   繁体   中英

How do I open Paytm app from Intent using Android?

I'm creating a food delivery app for restaurants for a university campus. Most of these restaurants accept Paytm as a payment method.

I want to add a button in my app to launch the Paytm app with the mobile number of the vendor and the amount of order filled in. So the user only has to press one button to complete the payment.I don't even need to receive payment confirmation from Paytm.

I can't use the payment API because it'll restrict the payment to only one account for which the API key is generated.

If it's not possible via intents, is it possible via deep linking?

I don't know how to open it directly, but so far I came up with the below code. It opens the browser and it will redirect to the app.

String url = "http://m.p-y.tm";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

you can use package name of PayTm like this,

String appPackageName = "net.one97.paytm";
                    PackageManager pm = getContext().getPackageManager();
                    Intent appstart = pm.getLaunchIntentForPackage(appPackageName);
                    if(null!=appstart)
                    {
                        getContext().startActivity(appstart);
                    }
                    else {
                        Toast.makeText(getContext(), "Install PayTm on your device", Toast.LENGTH_SHORT).show();
                    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM