Fixed IAB

This commit is contained in:
M66B 2016-07-17 18:49:07 +02:00
parent 6699557d2f
commit c61c0b15fd
1 changed files with 30 additions and 14 deletions

View File

@ -51,6 +51,14 @@ public class ActivityPro extends AppCompatActivity {
// adb shell pm clear com.android.vending // adb shell pm clear com.android.vending
// android.test.purchased // android.test.purchased
private static final int SKU_LOG_ID = 1;
private static final int SKU_FILTER_ID = 2;
private static final int SKU_NOTIFY_ID = 3;
private static final int SKU_SPEED_ID = 4;
private static final int SKU_THEME_ID = 5;
private static final int SKU_PRO1_ID = 6;
public static final String SKU_LOG = "log"; public static final String SKU_LOG = "log";
public static final String SKU_FILTER = "filter"; public static final String SKU_FILTER = "filter";
public static final String SKU_NOTIFY = "notify"; public static final String SKU_NOTIFY = "notify";
@ -146,22 +154,30 @@ public class ActivityPro extends AppCompatActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
try { try {
int id = 0;
PendingIntent pi = null; PendingIntent pi = null;
if (view == btnLog) if (view == btnLog) {
id = SKU_LOG_ID;
pi = iab.getBuyIntent(SKU_LOG); pi = iab.getBuyIntent(SKU_LOG);
else if (view == btnFilter) } else if (view == btnFilter) {
id = SKU_FILTER_ID;
pi = iab.getBuyIntent(SKU_FILTER); pi = iab.getBuyIntent(SKU_FILTER);
else if (view == btnNotify) } else if (view == btnNotify) {
id = SKU_NOTIFY_ID;
pi = iab.getBuyIntent(SKU_NOTIFY); pi = iab.getBuyIntent(SKU_NOTIFY);
else if (view == btnSpeed) } else if (view == btnSpeed) {
id = SKU_SPEED_ID;
pi = iab.getBuyIntent(SKU_SPEED); pi = iab.getBuyIntent(SKU_SPEED);
else if (view == btnTheme) } else if (view == btnTheme) {
id = SKU_THEME_ID;
pi = iab.getBuyIntent(SKU_THEME); pi = iab.getBuyIntent(SKU_THEME);
else if (view == btnAll) } else if (view == btnAll) {
id = SKU_PRO1_ID;
pi = iab.getBuyIntent(SKU_PRO1); pi = iab.getBuyIntent(SKU_PRO1);
}
if (pi != null) if (id > 0 && pi != null)
startIntentSenderForResult(pi.getIntentSender(), view.getId(), new Intent(), 0, 0, 0); startIntentSenderForResult(pi.getIntentSender(), id, new Intent(), 0, 0, 0);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
} }
@ -216,27 +232,27 @@ public class ActivityPro extends AppCompatActivity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
switch (requestCode) { switch (requestCode) {
case R.id.btnLog: case SKU_LOG_ID:
IAB.setBought(SKU_LOG, this); IAB.setBought(SKU_LOG, this);
updateState(); updateState();
break; break;
case R.id.btnFilter: case SKU_FILTER_ID:
IAB.setBought(SKU_FILTER, this); IAB.setBought(SKU_FILTER, this);
updateState(); updateState();
break; break;
case R.id.btnNotify: case SKU_NOTIFY_ID:
IAB.setBought(SKU_NOTIFY, this); IAB.setBought(SKU_NOTIFY, this);
updateState(); updateState();
break; break;
case R.id.btnSpeed: case SKU_SPEED_ID:
IAB.setBought(SKU_SPEED, this); IAB.setBought(SKU_SPEED, this);
updateState(); updateState();
break; break;
case R.id.btnTheme: case SKU_THEME_ID:
IAB.setBought(SKU_THEME, this); IAB.setBought(SKU_THEME, this);
updateState(); updateState();
break; break;
case R.id.btnAll: case SKU_PRO1_ID:
IAB.setBought(SKU_PRO1, this); IAB.setBought(SKU_PRO1, this);
updateState(); updateState();
break; break;