Android : Error getting default email with parse

on Monday, October 6, 2014


I'm implementing the UberVerificationSystem Library (https://github.com/FutureHax/UberVerificationSystem)


And i make it work in mi Galaxy Note 3, but when I try to make it work on my Xperia Arc S and my jiayu g2 it doesn't work.


In my note 3, i can open the app put a verification code and it works fine, but in the other phones when y try to open the app it crash and the log only shows this:


http://i.gyazo.com/968866e6156fca6490cf1b81fd02151a.png


It happens the same with the example that you can download of the library, in my note 3 works fine, but in the others crash.. I think that the app crashes because can't get the default email but i dont kno why. Because in my note 3 works fine..How can y solve this? code:



public class PurchaseActivity extends Activity implements IabHelper.OnIabSetupFinishedListener, IabHelper.OnIabPurchaseFinishedListener{
TextView message;
EditText txemail;
private IabHelper billingHelper;
private Button boton;
public ScrollView scrollpro1;
public ScrollView scrollpro2;
private String[] titulos;
private DrawerLayout NavDrawerLayout;
private ListView NavList;
private ArrayList<Item_objct> NavItms;
private TypedArray NavIcons;
private ActionBarDrawerToggle mDrawerToggle;
private CharSequence mDrawerTitle;
private CharSequence mTitle;
private LinearLayout LayoutAnuncio;
NavigationAdapter NavAdapter;


public PurchaseActivity(){


}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_purchase);
message = (TextView) findViewById(R.id.message);
txemail = (EditText) findViewById(R.id.txemail);
setupInstall();

//Purchase

boton = (Button) findViewById(R.id.boton);

boton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startBuyProcess();
}
});

//fin Purchase

}

public void setMessage() {
StringBuilder sb = new StringBuilder();
sb.append("Hello ");
String pEmail = Verifier.getInstallObject(this).getPrimaryEmail();
if (pEmail != null) {
sb.append(pEmail);
sb.append(".\n");
}

if (Verifier.getHasVerifiedCode(this)) {
sb.append("You have authenticated your code!");

scrollpro1 = (ScrollView) findViewById(R.id.scrollpro1);
scrollpro2 = (ScrollView) findViewById(R.id.scrollpro2);
scrollpro1.setVisibility(View.GONE);
scrollpro2.setVisibility(View.VISIBLE);
} else {
if (Verifier.getIsAppNuked(this)) {
sb.append(Verifier.getAppNukedMessage(this));
} else {
sb.append("Your demo is still valid.");
}
}

message.setText(sb.toString());
}

private void setupInstall() {
ParseInstallObject.createInstall(this,
new ParseInstallObject.IParseInstallFinished() {
@Override
public void finished(ParseInstallObject obj) {
setMessage();
}
}
);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
MenuItem upgrade = menu.findItem(R.id.action_upgrade);
MenuItem reset = menu.findItem(R.id.action_reset);
if (Verifier.getHasVerifiedCode(this)) {
menu.removeItem(upgrade.getItemId());
} else {
menu.removeItem(reset.getItemId());
}

return true;
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_upgrade) {
launchRedeemFlow();
return true;
} else if (id == R.id.action_reset) {
Verifier.reset(this);
invalidateOptionsMenu();
setMessage();
return true;
}
return super.onOptionsItemSelected(item);
}


// codigos pro//






protected void launchRedeemFlow() {
final ViewFlipper flippy = new ViewFlipper(this);
final EditText input = new EditText(this);
final ProgressBar pBar = new ProgressBar(this);
flippy.addView(input);
flippy.addView(pBar);

AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle("Redeem Code");
if (Verifier.getIsAppNuked(this)) {
b.setMessage(Verifier.getAppNukedMessage(this));
} else {
b.setMessage("Your demo is still valid");
}
b.setView(flippy);
b.setPositiveButton("Redeem", null);
final AlertDialog d = b.create();
d.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
launchRedeemCode(input.getText().toString(), d);
flippy.setDisplayedChild(1);
}
});
}
});
d.show();
}

protected void launchRedeemCode(String code, final AlertDialog d) {
VerificationCode.validateCode(this, code,
new VerificationCode.CodeValidationListener() {
@Override
public void onValidation(boolean success, boolean isValid, VerificationCode code) {
d.dismiss();
if (success) {
Log.d("THE CODE", code.toString());
if (isValid) {
AlertDialog.Builder b = new AlertDialog.Builder(
PurchaseActivity.this);
b.setTitle("Valid Code");
b.setMessage("Thank you! You have now removed the demo restrictions. Please restart the app.");
b.setPositiveButton("Restart",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
setupInstall();
invalidateOptionsMenu();
compraCorrecta();
}
}
);
b.create().show();
} else {
AlertDialog.Builder b = new AlertDialog.Builder(
PurchaseActivity.this);
b.setTitle("Invalid Code");
ParseInstallObject.InstallObject obj = Verifier.getInstallObject(PurchaseActivity.this);

if (code.attachedUser == null) {
b.setMessage("Please try again.");
} else {
if (!code.attachedUser.equalsIgnoreCase(obj
.getPrimaryEmail())) {
b.setMessage("This code has already been redeemed by another account.");
} else {
b.setMessage("Please try again.");
}
}
b.setPositiveButton("Dismiss",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
}
}
);
b.create().show();
}
}
}
}
);
}

0 comments:

Post a Comment