Guixe94
05/10/14, 23:08:01
Hola,
Estoy implementando una libreria que me genera codigos para que los usuarios puedan probar la versión pro durante un tiempo.. es esta: https://github.com/FutureHax/UberVerificationSystem me la puso un compañero en otro tema que abri.
Pues bien en mi Note 3 con android 4.4 me funciona todo perfecto pero en mi Xperia Arc S con android 4.1 al abrir la PurchaseActivity (donde tengo implementado lo de los codigos y eso..) se me cierra la app y en el log me pone que no puede haber un valor "null" pero no me indica cual ni nada.. (os dejo captura).
Estoy muy fastidiado por que me funciona bien pero he ido a probar en el otro por si acaso y nada.. y en un jiayu g2 tampoco me va..
os dejo el codigo de mi actividad y tambien la captura del log.
Creo que es por algo del GetPrimaryEmail.. pero no estoy seguro..
La libreria utiliza parse para guardar los codigos, email etc.
PurchaseActivity.Java:
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();
}
}
}
}
);
}
// fin codigos pro//
Log:
http://i.gyazo.com/968866e6156fca6490cf1b81fd02151a.png
Estoy implementando una libreria que me genera codigos para que los usuarios puedan probar la versión pro durante un tiempo.. es esta: https://github.com/FutureHax/UberVerificationSystem me la puso un compañero en otro tema que abri.
Pues bien en mi Note 3 con android 4.4 me funciona todo perfecto pero en mi Xperia Arc S con android 4.1 al abrir la PurchaseActivity (donde tengo implementado lo de los codigos y eso..) se me cierra la app y en el log me pone que no puede haber un valor "null" pero no me indica cual ni nada.. (os dejo captura).
Estoy muy fastidiado por que me funciona bien pero he ido a probar en el otro por si acaso y nada.. y en un jiayu g2 tampoco me va..
os dejo el codigo de mi actividad y tambien la captura del log.
Creo que es por algo del GetPrimaryEmail.. pero no estoy seguro..
La libreria utiliza parse para guardar los codigos, email etc.
PurchaseActivity.Java:
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();
}
}
}
}
);
}
// fin codigos pro//
Log:
http://i.gyazo.com/968866e6156fca6490cf1b81fd02151a.png