How to get Email Addresses of the invitees in Firebase? - java

I am trying to get e-mail address of the people the user has invited from my app
This is my code:
private void onInviteClicked() {
Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
.setMessage(getString(R.string.invitation_message))
.setDeepLink(Uri.parse(getString(R.string.invitation_deep_link)))
.setCustomImage(Uri.parse("http://jennstrends.com/wp-content/uploads/2013/10/bad-profile-pic-2.jpeg"))
.setCallToActionText(getString(R.string.invitation_cta)).setCallToActionText("email").build();
startActivityForResult(intent, REQUEST_INVITE);
}
int REQUEST_INVITE = 10101;
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode);
if (requestCode == REQUEST_INVITE) {
if (resultCode == RESULT_OK) {
// Get the invitation IDs of all sent messages
final String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
final List<String> members = new ArrayList();
members.add(GoogleAuthHelper.getInstance().getUser().getProjectId());
for (String id : ids) {
members.add(id);
}
ApiClient.getInstance(getBaseContext()).addMembers(members, new OnPostListener<String>() {
#Override
public void onError(ANError error) {
Log.e("Server", "Members: " + error.getErrorCode());
}
#Override
public void onResponse(String val) {
Log.d("Server", "Response from Member: " + val.toString());
}
});
} else {
// Sending failed or it was canceled, show failure message to
// the user
// ...
Log.d("Server", "Invitation Failed code: " + resultCode);
}
}
}
Now how do I get the email addresses of the list of people the user has invited. AppInviteInvitation.getInvitationIds() are not the email ids. Someone help me out! Please!

Related

get onActivityResult from externall app Andriod

My App1 launch App2:
case R.id.launch_button: {
try {
Intent intent = getPackageManager().getLaunchIntentForPackage("com.app1");
intent.putExtra("Price", getAmount());
intent.putExtra("Description", getProductId());
startActivityForResult(intent, PAYMENT_REQUEST);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
Log.i(TAG, "Activity not found" );
}
break;
}
When App2 finish processing should return RESULT_OK or RESULT_CANCELED:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.i(TAG, "onActivityResult " + requestCode + " " + resultCode + " " + data);
if (requestCode == PAYMENT_REQUEST) {
if (resultCode == Activity.RESULT_OK) {
Toast.makeText(this, "Payment success", Toast.LENGTH_LONG).show();
}
if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(this, "Payment fail", Toast.LENGTH_LONG).show();
}
}
}
but RESULT_CANCELED appears immediately when the App2 launch.
Why am I receiving RESULT_CANCELED before even the App2 launch? What I'm doing wrong?
App2 return result code:
#Override
public void onPaymentSuccess() {
activity.setResult(Activity.RESULT_OK);
activity.finish();
}
#Override
public void onPaymentFail() {
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
}
I also dont receive any result when App2 finish..
Note: App2 use Fragment

How To Log In To Google Account - api 28

I am trying to set a logIn/signUp to a google account. I wrote the code and it should work but it doesn't(it always ends up with the failed toast I made).
I watch a bunch of videos and looked at google doc and my code is pretty much the same.
protected void onStart() {
if( getIntent().getBooleanExtra(ThirdActivity.extraLoggedIn, false) == false ) {
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
if (account != null) {
getDataFromFirebase(account);
//playerNameText.setText("Player Name: " + accountName);
} else {
startActivityForResult(mGoogleSignInClient.getSignInIntent(), 0);
//account = GoogleSignIn.getLastSignedInAccount(this);
//signUp(account);
}
loggedIn = true;
}
super.onStart();
changeLanguage(SingletonDemiClass.getInstance().getLanguage());
playerNameText.setText("Player Name: " + accountName);
}
#Override
public void onActivityResult(int requestCode, int resultCode, #Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 0){
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
//Toast.makeText(SecondActivity.this, task.getResult().getId(), Toast.LENGTH_LONG).show();
signUp(task);
}
}
//private void signUp(GoogleSignInAccount account) {
private void signUp(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
accountID = account.getId();
accountName = account.getDisplayName();
}
catch (ApiException ex) {
Log.w("Google Sign-In Error", "signInResult:failed code=" + ex.getStatusCode());
Toast.makeText(SecondActivity.this, "Failed", Toast.LENGTH_LONG).show();
//}
}
}
Logcat

"Webpage not available, the webpage at http://xxx.xxx.xxx.xx:3000/pgSimulator/axis/redirect could not be loaded. net::ERR_CLEARTEXT_NOT_PERMITTED"

I am integrating payumoney payment gateway on my Android app. But when I tried to make an test transaction by a test debit card. It shows an error.
when i contact to the payumoney customer care they said to whitelist the url to the server. i dont know how to whitelist url ito server.
public void startpay() {
builder.setAmount(amount) // Payment amount
.setTxnId(txnid) // Transaction ID
.setPhone(phone) // User Phone number
.setProductName(prodname) // Product Name or description
.setFirstName(firstname) // User First name
.setEmail(email) // User Email ID
.setsUrl("https://www.payumoney.com/mobileapp/payumoney/success.php") // Success URL (surl)
.setfUrl("https://www.payumoney.com/mobileapp/payumoney/failure.php") //Failure URL (furl)
.setUdf1("")
.setUdf2("")
.setUdf3("")
.setUdf4("")
.setUdf5("")
.setUdf6("")
.setUdf7("")
.setUdf8("")
.setUdf9("")
.setUdf10("")
.setIsDebug(true) // Integration environment - true (Debug)/ false(Production)
.setKey(merchantkey) // Merchant key
.setMerchantId(merchantId);
try {
paymentParam = builder.build();
// generateHashFromServer(paymentParam );
getHashkey();
} catch (Exception e) {
Log.e(TAG, " error s " + e.toString());
}
}
public void getHashkey() {
ServiceWrapper service = new ServiceWrapper(null);
Call<String> call = service.newHashCall(merchantkey, txnid, amount, prodname,
firstname, email);
call.enqueue(new Callback<String>() {
#Override
public void onResponse(Call<String> call, Response<String> response) {
Log.e(TAG, "hash res " + response.body());
String merchantHash = response.body();
if (merchantHash.isEmpty() || merchantHash.equals("")) {
Toast.makeText(StartPaymentActivity.this, "Could not generate hash", Toast.LENGTH_SHORT).show();
Log.e(TAG, "hash empty");
} else {
// mPaymentParams.setMerchantHash(merchantHash);
paymentParam.setMerchantHash(merchantHash);
// Invoke the following function to open the checkout page.
// PayUmoneyFlowManager.startPayUMoneyFlow(paymentParam, StartPaymentActivity.this,-1, true);
PayUmoneyFlowManager.startPayUMoneyFlow(paymentParam, StartPaymentActivity.this, R.style.AppTheme_default, false);
}
}
#Override
public void onFailure(Call<String> call, Throwable t) {
Log.e(TAG, "hash error " + t.toString());
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//PayUMoneySdk: Success -- merchantResponse438104
// on successfull txn
// request code 10000 resultcode -1
// Result Code is -1 send from Payumoney activity
Log.e("StartPaymentActivity", "request code " + requestCode + " resultcode " + resultCode);
if (requestCode == PayUmoneyFlowManager.REQUEST_CODE_PAYMENT && resultCode == RESULT_OK && data != null) {
TransactionResponse transactionResponse = data.getParcelableExtra(PayUmoneyFlowManager.INTENT_EXTRA_TRANSACTION_RESPONSE);
if (transactionResponse != null && transactionResponse.getPayuResponse() != null) {
if (transactionResponse.getTransactionStatus().equals(TransactionResponse.TransactionStatus.SUCCESSFUL)) {
//Success Transaction
Toast.makeText(this, "Payment successful", Toast.LENGTH_SHORT).show();
} else {
//Failure Transaction
Toast.makeText(this, "Payment failed", Toast.LENGTH_SHORT).show();
}
// Response from Payumoney
//String payuResponse = transactionResponse.getPayuResponse();
// Response from SURl and FURL
//String merchantResponse = transactionResponse.getTransactionDetails();
//Log.e(TAG, "tran " + payuResponse + "---" + merchantResponse);
} /* else if (resultModel != null && resultModel.getError() != null) {
Log.d(TAG, "Error response : " + resultModel.getError().getTransactionResponse());
} else {
Log.d(TAG, "Both objects are null!");
}*/
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//PayUMoneySdk: Success -- merchantResponse438104
// on successfull txn
// request code 10000 resultcode -1
// Result Code is -1 send from Payumoney activity
Log.e("StartPaymentActivity", "request code " + requestCode + " resultcode " + resultCode);
if (requestCode == PayUmoneyFlowManager.REQUEST_CODE_PAYMENT && resultCode == RESULT_OK && data != null) {
TransactionResponse transactionResponse = data.getParcelableExtra(PayUmoneyFlowManager.INTENT_EXTRA_TRANSACTION_RESPONSE);
if (transactionResponse != null && transactionResponse.getPayuResponse() != null) {
if (transactionResponse.getTransactionStatus().equals(TransactionResponse.TransactionStatus.SUCCESSFUL)) {
//Success Transaction
Toast.makeText(this, "Payment successful", Toast.LENGTH_SHORT).show();
} else {
//Failure Transaction
Toast.makeText(this, "Payment failed", Toast.LENGTH_SHORT).show();
}
// Response from Payumoney
//String payuResponse = transactionResponse.getPayuResponse();
// Response from SURl and FURL
//String merchantResponse = transactionResponse.getTransactionDetails();
//Log.e(TAG, "tran " + payuResponse + "---" + merchantResponse);
}
}
}
Please keep this line in your android manifest file under application tag android:usesCleartextTraffic="true" as shown below
AndroidManifest.xml
<application
android:usesCleartextTraffic="true">
</application>
Please keep this line in your android manifest file under application tag android:usesCleartextTraffic="true" as shown below
<application
android:usesCleartextTraffic="true"
tools:replace="usesCleartextTraffic">
</application>
This is happening because web url is HTTP instead of HTTPS (http://XXX.XXX.XXX.XX:3000/.....)
This is already answered here.
Android 8: Cleartext HTTP traffic not permitted

Why does the OnSuccess method of getPlayersClient() never run?

When integrating Google Play Games Sign-in, I needed to get the player name for my app, but the getCurrentPlayer() task never completed (playerName is perpetually null). OnActivityResult is ran from a startActivityForResult with the intent from the getSignInIntent() method of a GoogleSignInClient.
Here's the relevant code from onActivityResult (playerName is Global):
#Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from signInClient
if (requestCode == SIGN_IN) {
Task<GoogleSignInAccount> resTask =
GoogleSignIn.getSignedInAccountFromIntent(data);
if (resTask.isSuccessful()) {
GoogleSignInAccount resAcct = resTask.getResult();
PlayersClient playersClient = Games.getPlayersClient(this, resAcct);
playersClient.getCurrentPlayer()
.addOnSuccessListener(new OnSuccessListener<Player>() {
#Override
public void onSuccess(Player taskPlayer) {
playerName = taskPlayer.getName();
}
});
while(playerName==null){
Log.d("OH GOD WHY", "WHY???");
}
//Do something with the name
...
} else {
Toast.makeText(getApplicationContext(), "Unable to sign in. Please try again later.", Toast.LENGTH_SHORT).show();
}
}
}
Before using OnSuccess, I was using OnComplete, but that never ran either (the isSuccessful() check never ran here):
playersClient.getCurrentPlayer()
.addOnCompleteListener(new OnCompleteListener<Player>() {
#Override
public void onComplete(Task<Player> pTask) {
if(pTask.isSuccessful()){
Player player = pTask.getResult();
playerName = player.getName();
} else {
//Handle error
...
}
}
});

Android/Java How getGender getBirthday and so on from googleApiClient

This is part of the code, and the question is, how can I INTENT this values
Log.i(TAG, "Display Name: " + person.getDisplayName());
Log.i(TAG, "Gender: " + person.getGender());
Log.i(TAG, "About Me: " + person.getAboutMe());
Log.i(TAG, "Birthday: " + person.getBirthday());
Log.i(TAG, "Current Location: " + person.getCurrentLocation());
Log.i(TAG, "Language: " + person.getLanguage());
To another activity.
My idea which do not work is to do it like this
userGenderG = person.getGender();
userAboutG = person.getAboutMe();
userBirthdayG = person.getBirthday();
userLanguageG = person.getLanguage();
Unsuccessful idea.
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
// G+
if (mGoogleApiClient.hasConnectedApi(Plus.API)) {
Person person = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
if (person != null) {
Log.i(TAG, "--------------------------------");
Log.i(TAG, "Display Name: " + person.getDisplayName());
Log.i(TAG, "Gender: " + person.getGender());
Log.i(TAG, "About Me: " + person.getAboutMe());
Log.i(TAG, "Birthday: " + person.getBirthday());
Log.i(TAG, "Current Location: " + person.getCurrentLocation());
Log.i(TAG, "Language: " + person.getLanguage());
userGenderG = person.getGender();
userAboutG = person.getAboutMe();
userBirthdayG = person.getBirthday();
userLanguageG = person.getLanguage();
} else {
Log.e(TAG, "Error!");
}
} else {
Log.e(TAG, "Google+ not connected");
}
}
}
Any suggestion about how could I user gender as value and intent them to another activity?
UPDATED (how send data)
GoToNewActivity.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Index.class);
Bundle extras = new Bundle();
extras.putString("userGender", userGenderG);
extras.putString("userAbout", userAboutG);
extras.putString("userBirthday", userBirthdayG);
extras.putString("userLanguage", userLanguageG);
intent.putExtras(extras);
startActivity(intent);
}
});

Categories

Resources