本文整理汇总了Java中com.soomla.SoomlaApp类的典型用法代码示例。如果您正苦于以下问题:Java SoomlaApp类的具体用法?Java SoomlaApp怎么用?Java SoomlaApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SoomlaApp类属于com.soomla包,在下文中一共展示了SoomlaApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStart
import com.soomla.SoomlaApp; //导入依赖的package包/类
@Override
protected void onStart() {
SoomlaUtils.LogDebug(TAG, "onStart 1");
super.onStart();
if (!firstTime && SoomlaApp.getAppContext() instanceof Activity) {
SoomlaUtils.LogDebug(TAG, "onStart 2");
onActivityResult(10001, Activity.RESULT_CANCELED, null);
Intent tabIntent = new Intent(this, ((Activity) SoomlaApp.getAppContext()).getClass());
tabIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
SoomlaUtils.LogDebug(TAG, "onStart 3");
startActivity(tabIntent);
}
SoomlaUtils.LogDebug(TAG, "onStart 4");
}
示例2: onSoomlaStoreInitializedEvent
import com.soomla.SoomlaApp; //导入依赖的package包/类
@Subscribe
public void onSoomlaStoreInitializedEvent(SoomlaStoreInitializedEvent soomlaStoreInitializedEvent) {
//FOR TESTING PURPOSES ONLY: Check if it's a first run, if so add 10000 currencies.
SharedPreferences prefs =
SoomlaApp.getAppContext().getSharedPreferences("config",
Context.MODE_PRIVATE);
boolean initialized = prefs.getBoolean(FIRST_RUN, false);
if (!initialized) {
try {
for (VirtualCurrency currency : storeAssets.getCurrencies()) {
StoreInventory.giveVirtualItem(currency.getItemId(), 10000);
}
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(FIRST_RUN, true);
edit.commit();
} catch (VirtualItemNotFoundException e) {
SoomlaUtils.LogError("Example Activity", "Couldn't add first 10000 currencies.");
}
}
progress.dismiss();
}
示例3: setPublicKey
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Sets the public key for Google Play IAB Service.
* This function MUST be called once when the application loads and after SoomlaStore
* initializes.
*
* @param publicKey the public key from the developer console.
*/
public void setPublicKey(String publicKey) {
SharedPreferences prefs = SoomlaApp.getAppContext().
getSharedPreferences(SoomlaConfig.PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor edit = prefs.edit();
if (publicKey != null && publicKey.length() != 0) {
edit.putString(PUBLICKEY_KEY, publicKey);
} else if (prefs.getString(PUBLICKEY_KEY, "").length() == 0) {
String err = "publicKey is null or empty. Can't initialize store!!";
SoomlaUtils.LogError(TAG, err);
}
edit.commit();
}
示例4: launchPurchaseFlow
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* see parent
*/
@Override
public void launchPurchaseFlow(String sku,
final IabCallbacks.OnPurchaseListener purchaseListener,
String extraData) {
SharedPreferences prefs = SoomlaApp.getAppContext().
getSharedPreferences(SoomlaConfig.PREFS_NAME, Context.MODE_PRIVATE);
String publicKey = prefs.getString(PUBLICKEY_KEY, "");
if (publicKey.length() == 0 || publicKey.equals("[YOUR PUBLIC KEY FROM THE MARKET]")) {
SoomlaUtils.LogError(TAG, "You didn't provide a public key! You can't make purchases. the key: " + publicKey);
throw new IllegalStateException();
}
try {
final Intent intent = new Intent(SoomlaApp.getAppContext(), IabActivity.class);
intent.putExtra(SKU, sku);
intent.putExtra(EXTRA_DATA, extraData);
mSavedOnPurchaseListener = purchaseListener;
if (SoomlaApp.getAppContext() instanceof Activity) {
Activity activity = (Activity) SoomlaApp.getAppContext();
activity.startActivity(intent);
} else {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
SoomlaApp.getAppContext().startActivity(intent);
}
} catch(Exception e){
String msg = "(launchPurchaseFlow) Error purchasing item " + e.getMessage();
SoomlaUtils.LogError(TAG, msg);
purchaseListener.fail(msg);
}
}
示例5: dispose
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Dispose of object, releasing resources. It's very important to call this
* method when you are done with this object. It will release any resources
* used by it such as service connections. Naturally, once the object is
* disposed of, it can't be used again.
*/
public void dispose() {
SoomlaUtils.LogDebug(TAG, "Disposing.");
super.dispose();
if (mServiceConn != null) {
SoomlaUtils.LogDebug(TAG, "Unbinding from service.");
if (SoomlaApp.getAppContext() != null && mService != null) SoomlaApp.getAppContext().unbindService(mServiceConn);
mServiceConn = null;
mService = null;
}
}
示例6: consume
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Consumes a given in-app product. Consuming can only be done on an item
* that's owned, and as a result of consumption, the user will no longer own it.
* This method may block or take long to return. Do not call from the UI thread.
* For that, see {@link #consumeAsync}.
*
* @param itemInfo The PurchaseInfo that represents the item to consume.
* @throws IabException if there is a problem during consumption.
*/
public void consume(IabPurchase itemInfo) throws IabException {
checkSetupDoneAndThrow("consume");
if (!itemInfo.getItemType().equals(ITEM_TYPE_INAPP)) {
throw new IabException(IabResult.IABHELPER_INVALID_CONSUMPTION,
"Items of type '" + itemInfo.getItemType() + "' can't be consumed.");
}
try {
String token = itemInfo.getToken();
String sku = itemInfo.getSku();
if (token == null || token.equals("")) {
SoomlaUtils.LogError(TAG, "Can't consume "+ sku + ". No token.");
throw new IabException(IabResult.IABHELPER_MISSING_TOKEN, "PurchaseInfo is missing token for sku: "
+ sku + " " + itemInfo);
}
SoomlaUtils.LogDebug(TAG, "Consuming sku: " + sku + ", token: " + token);
int response = mService.consumePurchase(3, SoomlaApp.getAppContext().getPackageName(), token);
if (response == IabResult.BILLING_RESPONSE_RESULT_OK) {
SoomlaUtils.LogDebug(TAG, "Successfully consumed sku: " + sku);
}
else {
SoomlaUtils.LogDebug(TAG, "Error consuming consuming sku " + sku + ". " + IabResult.getResponseDesc(response));
throw new IabException(response, "Error consuming sku " + sku);
}
}
catch (RemoteException e) {
throw new IabException(IabResult.IABHELPER_REMOTE_EXCEPTION, "Remote exception while consuming. PurchaseInfo: " + itemInfo, e);
}
}
示例7: querySkuDetailsChunk
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Queries a chunk of SKU details to prevent Google's 20 items bug.
*
* @throws RemoteException
* @throws JSONException
*/
private int querySkuDetailsChunk(String itemType, IabInventory inv, ArrayList<String> chunkSkuList) throws RemoteException, JSONException {
Bundle querySkus = new Bundle();
querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, chunkSkuList);
Bundle skuDetails = mService.getSkuDetails(3, SoomlaApp.getAppContext().getPackageName(),
itemType, querySkus);
if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
int response = getResponseCodeFromBundle(skuDetails);
if (response != IabResult.BILLING_RESPONSE_RESULT_OK) {
SoomlaUtils.LogDebug(TAG, "querySkuDetailsChunk() failed: " + IabResult.getResponseDesc(response));
return response;
}
else {
SoomlaUtils.LogError(TAG, "querySkuDetailsChunk() returned a bundle with neither an error nor a detail list.");
return IabResult.IABHELPER_BAD_RESPONSE;
}
}
ArrayList<String> responseList = skuDetails.getStringArrayList(
RESPONSE_GET_SKU_DETAILS_LIST);
for (String thisResponse : responseList) {
IabSkuDetails d = new IabSkuDetails(itemType, thisResponse);
SoomlaUtils.LogDebug(TAG, "Got sku details: " + d);
inv.addSkuDetails(d);
}
return IabResult.BILLING_RESPONSE_RESULT_OK;
}
示例8: KeyValueStorage
import com.soomla.SoomlaApp; //导入依赖的package包/类
public KeyValueStorage(String storageName, String secret) {
KeevaConfig.logDebug = SoomlaConfig.logDebug;
try {
Field obfuscationSaltField = KeevaConfig.class.getDeclaredField("obfuscationSalt");
obfuscationSaltField.setAccessible(true);
obfuscationSaltField.set(null, SoomlaConfig.obfuscationSalt);
Field dbDeleteField = KeevaConfig.class.getDeclaredField("DB_DELETE");
dbDeleteField.setAccessible(true);
dbDeleteField.set(null, SoomlaConfig.DB_DELETE);
} catch (Exception e) {
SoomlaUtils.LogError(TAG, "Error setting SOOMLA's config to Keeva " + e.getLocalizedMessage());
}
mKeeva = new Keeva(SoomlaApp.getAppContext(), storageName, secret);
}
示例9: showToastIfDebug
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Posts to Handler if <code>SoomlaConfig</code>'s <code>logDebug</code> is set to true.
* Enqueues a <code>Runnable</code> object to be called by the message queue when it is
* received. The <code>Runnable</code> displays a debug message.
*
* @param msg message to be displayed as a part of the <code>Runnable</code>'s <code>run</code> method.
*/
private void showToastIfDebug(final String msg) {
if (SoomlaConfig.logDebug){
mHandler.post(new Runnable() {
@Override
public void run() {
Toast toast = Toast.makeText(SoomlaApp.getAppContext(), msg, Toast.LENGTH_SHORT);
toast.show();
}
});
}
}
示例10: multiShare
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Shares text and/or image using native sharing functionality of your target platform.
* @param text Text to share
* @param imageFilePath Path to an image file to share
*/
public void multiShare(String text, String imageFilePath) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
if (imageFilePath != null) {
sharingIntent.setType("*/*");
Uri uri = Uri.parse("file://" + imageFilePath);
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
} else {
sharingIntent.setType("text/plain");
}
sharingIntent.putExtra(Intent.EXTRA_TEXT, text);
Intent chooser = Intent.createChooser(sharingIntent, "Share");
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
SoomlaApp.getAppContext().startActivity(chooser);
}
示例11: getTempImageDir
import com.soomla.SoomlaApp; //导入依赖的package包/类
private String getTempImageDir(){
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())){
SoomlaUtils.LogDebug(TAG, "(getTempImageDir) External storage not ready.");
return null;
}
ContextWrapper soomContextWrapper = new ContextWrapper(SoomlaApp.getAppContext());
return Environment.getExternalStorageDirectory() + soomContextWrapper.getFilesDir().getPath() + "/temp/";
}
示例12: launchPurchaseFlow
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* see parent
*/
@Override
public void launchPurchaseFlow(String itemType,
String sku,
final IabCallbacks.OnPurchaseListener purchaseListener,
String extraData) {
SharedPreferences prefs = SoomlaApp.getAppContext().
getSharedPreferences(SoomlaConfig.PREFS_NAME, Context.MODE_PRIVATE);
String publicKey = prefs.getString(PUBLICKEY_KEY, "");
if (publicKey.length() == 0 || publicKey.equals("[YOUR PUBLIC KEY FROM THE MARKET]")) {
SoomlaUtils.LogError(TAG, "You didn't provide a public key! You can't make purchases. the key: " + publicKey);
throw new IllegalStateException();
}
try {
final Intent intent = new Intent(SoomlaApp.getAppContext(), IabActivity.class);
intent.putExtra(SKU, sku);
intent.putExtra(ITEM_TYPE, itemType);
intent.putExtra(EXTRA_DATA, extraData);
mSavedOnPurchaseListener = purchaseListener;
if (SoomlaApp.getAppContext() instanceof Activity) {
Activity activity = (Activity) SoomlaApp.getAppContext();
activity.startActivity(intent);
} else {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
SoomlaApp.getAppContext().startActivity(intent);
}
} catch(Exception e){
String msg = "(launchPurchaseFlow) Error purchasing item " + e.getMessage();
SoomlaUtils.LogError(TAG, msg);
purchaseListener.fail(msg);
}
}
示例13: consume
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Consumes a given in-app product. Consuming can only be done on an item
* that's owned, and as a result of consumption, the user will no longer own it.
* This method may block or take long to return. Do not call from the UI thread.
* For that, see {@link #consumeAsync}.
*
* @param itemInfo The PurchaseInfo that represents the item to consume.
* @throws IabException if there is a problem during consumption.
*/
public void consume(IabPurchase itemInfo) throws IabException {
checkSetupDoneAndThrow("consume");
if (!itemInfo.getItemType().equals(ITEM_TYPE_INAPP)) {
throw new IabException(IabResult.IABHELPER_INVALID_CONSUMPTION,
"Items of type '" + itemInfo.getItemType() + "' can't be consumed.");
}
try {
String token = itemInfo.getToken();
String sku = itemInfo.getSku();
if (token == null || token.equals("")) {
SoomlaUtils.LogError(TAG, "Can't consume "+ sku + ". No token.");
throw new IabException(IabResult.IABHELPER_MISSING_TOKEN, "PurchaseInfo is missing token for sku: "
+ sku + " " + itemInfo);
}
SoomlaUtils.LogDebug(TAG, "Consuming sku: " + sku + ", token: " + token);
int response = mService.consumePurchase(3, SoomlaApp.getAppContext().getPackageName(), token);
if (response == IabResult.BILLING_RESPONSE_RESULT_OK) {
SoomlaUtils.LogDebug(TAG, "Successfully consumed sku: " + sku);
}
else {
SoomlaUtils.LogDebug(TAG, "Error consuming sku " + sku + ". " + IabResult.getResponseDesc(response));
throw new IabException(response, "Error consuming sku " + sku);
}
}
catch (RemoteException e) {
throw new IabException(IabResult.IABHELPER_REMOTE_EXCEPTION, "Remote exception while consuming. PurchaseInfo: " + itemInfo, e);
}
}
示例14: startSetupInner
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* See parent
*/
protected void startSetupInner() {
SoomlaUtils.LogDebug(TAG, "startSetupInner launched");
mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
SoomlaUtils.LogDebug(TAG, "Billing service disconnected.");
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
SoomlaUtils.LogDebug(TAG, "Billing service connected.");
mService = INokiaIAPService.Stub.asInterface(service);
String packageName = SoomlaApp.getAppContext().getPackageName();
try {
SoomlaUtils.LogDebug(TAG, "Checking for in-app billing 3 support.");
// check for in-app billing v3 support
int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP);
if (response != IabResult.BILLING_RESPONSE_RESULT_OK) {
setupFailed(new IabResult(response, "Error checking for billing v3 support."));
return;
}
SoomlaUtils.LogDebug(TAG, "In-app billing version 3 supported for " + packageName);
setupSuccess();
}
catch (RemoteException e) {
setupFailed(new IabResult(IabResult.IABHELPER_REMOTE_EXCEPTION, "RemoteException while setting up in-app billing."));
e.printStackTrace();
}
}
};
SoomlaApp.getAppContext().bindService(new Intent("com.nokia.payment.iapenabler.InAppBillingService.BIND"), mServiceConn, Context.BIND_AUTO_CREATE);
}
示例15: consume
import com.soomla.SoomlaApp; //导入依赖的package包/类
/**
* Consumes a given in-app product. Consuming can only be done on an item
* that's owned, and as a result of consumption, the user will no longer own it.
* This method may block or take long to return. Do not call from the UI thread.
* For that, see {@link #consumeAsync}.
*
* @param itemInfo The PurchaseInfo that represents the item to consume.
* @throws IabException if there is a problem during consumption.
*/
public void consume(IabPurchase itemInfo) throws IabException {
checkSetupDoneAndThrow("consume");
if (!itemInfo.getItemType().equals(ITEM_TYPE_INAPP)) {
throw new IabException(IabResult.IABHELPER_INVALID_CONSUMPTION,
"Items of type '" + itemInfo.getItemType() + "' can't be consumed.");
}
try {
String token = itemInfo.getToken();
String sku = itemInfo.getSku();
if (token == null || token.equals("")) {
SoomlaUtils.LogError(TAG, "Can't consume "+ sku + ". No token.");
throw new IabException(IabResult.IABHELPER_MISSING_TOKEN, "PurchaseInfo is missing token for sku: "
+ sku + " " + itemInfo);
}
SoomlaUtils.LogDebug(TAG, "Consuming sku: " + sku + ", token: " + token);
int response = mService.consumePurchase(3, SoomlaApp.getAppContext().getPackageName(), sku, token);
if (response == IabResult.BILLING_RESPONSE_RESULT_OK) {
SoomlaUtils.LogDebug(TAG, "Successfully consumed sku: " + sku);
}
else {
SoomlaUtils.LogDebug(TAG, "Error consuming consuming sku " + sku + ". " + IabResult.getResponseDesc(response));
throw new IabException(response, "Error consuming sku " + sku);
}
}
catch (RemoteException e) {
throw new IabException(IabResult.IABHELPER_REMOTE_EXCEPTION, "Remote exception while consuming. PurchaseInfo: " + itemInfo, e);
}
}