我刷新到 android billing 版本 4 和 2 的东西不再工作了。
首先我有这个:
else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED) {
Purchase.PurchasesResult queryAlreadyPurchasesResult = billingClient.queryPurchases(INAPP); // deprecated
List<Purchase> alreadyPurchases = queryAlreadyPurchasesResult.getPurchasesList();
if(alreadyPurchases!=null){
handlePurchases(alreadyPurchases);
}
}
Run Code Online (Sandbox Code Playgroud)
不推荐使用 queryPurchases。
其次我有这个:
void handlePurchases(List<Purchase> purchases) {
for(Purchase purchase:purchases) {
//if item is purchased
if (PRODUCT_ID.equals(purchase.getSku()) && purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED)
{
if (!verifyValidSignature(purchase.getOriginalJson(), purchase.getSignature())) {
// Invalid purchase
// show error to user
Toast.makeText(getApplicationContext(), R.string.plus_error, Toast.LENGTH_SHORT).show();
return;
}
Run Code Online (Sandbox Code Playgroud)
getSku() 正在工作,但现在它被标记为 Cannot resolve method getSku() in Purchase
任何想法如何解决这个问题?
从文档:
Summary of changes …Run Code Online (Sandbox Code Playgroud) 我想使用 android billing 版本 5。问题是我使用的是版本 3,有些功能现在已弃用。
我有这个,但PurchasesResult、queryPurchases 和 getPurchasesList 不再存在:
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if(billingResult.getResponseCode()==BillingClient.BillingResponseCode.OK){
Purchase.PurchasesResult queryPurchase = billingClient.queryPurchases(INAPP);
List<Purchase> queryPurchases = queryPurchase.getPurchasesList();
if(queryPurchases!=null && queryPurchases.size()>0){
handlePurchases(queryPurchases);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它在版本 5 上工作?
也无法解析 getSku():
//if purchase is pending
else if( PRODUCT_ID.equals(purchase.getSku()) && purchase.getPurchaseState() == Purchase.PurchaseState.PENDING)
{
Toast.makeText(getApplicationContext(),
R.string.plus_pending, Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个正则表达式从textarea获取@user.当用户用@键入内容时,我会得到它.
我的问题是,我想得到最后一场比赛,而不是所有比赛.
例如:
用户类型:
@josh and @marie = want to show @marie
@josh loves @marie and @anne = show @anne
Run Code Online (Sandbox Code Playgroud)
我的代码显示如下:
@josh,@marie,@anne
Run Code Online (Sandbox Code Playgroud)
我可以获得最后一个@something条目吗?(当用户打字时)
var word=/@(\w+)/ig;
$("#comment").on("keyup",function() {
var content = $(this).val();
var name = content.match(word);
var dataString = name;
if(name.length > 0) {
$("#result").text(name);
}
return false();
});
Run Code Online (Sandbox Code Playgroud)
HTML
<textarea id=comment>@josh and @marie</textarea>
<div id=result></div>
Run Code Online (Sandbox Code Playgroud)
https://jsfiddle.net/dcs5pat8/(按textarea)
我需要在 jQuery 中获取一个数字值,但要使其正常工作,我的div.
<div class="button" id="button$post" numberlk="$total">
Run Code Online (Sandbox Code Playgroud)
这工作正常!但是 HTML 验证器告诉我:
错误:此时元素 div 上不允许使用属性 numberlk。
我该怎么做才能使其正常工作?
我的脚本中有这个:
for(var i = 0, l = eachLine.length; i < l; i++) {
if(eachLine[i].length>0){
doP(eachLine[i], +i);
}
}
Run Code Online (Sandbox Code Playgroud)
for 从字符串中读取行并调用 doP 函数。发生的情况是它太快了,并根据文本大小在我的网页上造成了一些速度问题。
我想要的是每 10 秒调用一次 doP 函数......换句话说,我想等待 10 秒再次调用 doP 函数......我怎样才能让它工作?
我有一个带图像的标题和带有一些项目的RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/header"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#ffffff">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="0dp"
android:id="@+id/imageView"
android:adjustViewBounds="true"
android:cropToPadding="false" />
</RelativeLayout>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:scrollbars="vertical"
android:layout_alignParentLeft="true" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
RelativeLayout固定在RecyclerView之上.我想要的是滚动RecyclerView时滚动此标题(RelativeLayout).
有关如何使用RecyclerView滚动标题的任何想法?
我在我的应用程序中使用anjlab https://github.com/anjlab/android-inapp-billing-v3进行计费.
我是android studio的新手,我想要一些关于代码的帮助.
bp.getPurchaseListingDetails("YOUR PRODUCT ID FROM GOOGLE PLAY CONSOLE HERE");
Run Code Online (Sandbox Code Playgroud)
因此,它将是一个SkuDetails对象,包含以下信息:
public final String productId; public final String title; public final字符串描述; public final boolean isSubscription; public final String currency; 公共最终双倍价格; public final String priceText;
好的,所以我想得到,例如,产品价格,我正在尝试:
String price = bp.getPurchaseListingDetails("productidname").priceText;
pricevalue.setText(price);
Run Code Online (Sandbox Code Playgroud)
它返回null.我做错了什么?
我有这个:
$( document ).on( "click", ".showcomments", function() {
alert("ok");
var element = $(this);
var id = element.attr("data-postid");
$(element).removeClass('showcomments'); //remove class after click to avoid double call to this function
});
Run Code Online (Sandbox Code Playgroud)
和HTML:
<a href="javascript:;" class="showcomments" data-postid="'1'">1</a>
<a href="javascript:;" class="showcomments" data-postid="'2'">2</a>
<a href="javascript:;" class="showcomments" data-postid="'3'">3</a>
<a href="javascript:;" class="showcomments" data-postid="'1'">1</a>
Run Code Online (Sandbox Code Playgroud)
当用户点击2时,例如,它将从该类中删除类showcomments,用户将无法再点击2.
问题是当用户点击1(第一个或第二个链接)时,我想从页面中的所有1个链接(data-postid)中删除showcomments类.我不希望用户能够再次点击任何1.有任何想法如何从页面中的任何1删除类?
我得到 exif 来读取上传图像的方向。问题是在某些图像中我收到此错误:
警告 exif_read_data(php3KLADx):第 5 行的 /home/i/public_html/orientation.php 中不支持文件
任何想法如何避免这种情况?
<?php
function exif_orientation($file_tmp) {
$image = imagecreatefromstring(file_get_contents($file_tmp));
$exif = exif_read_data($file_tmp);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$image = imagerotate($image,90,0);
break;
case 3:
$image = imagerotate($image,180,0);
break;
case 6:
$image = imagerotate($image,-90,0);
break;
}
imagejpeg($image, $file_tmp, 90);
}
}
?>
Run Code Online (Sandbox Code Playgroud) 我想从字符串中删除一些单词以使我的图像alt标签更相关.
问题是,如果我有这样的阶段:
barack obama at a restaurant in venice
Run Code Online (Sandbox Code Playgroud)
我希望退出是:
barack obama restaurant venice
Run Code Online (Sandbox Code Playgroud)
但我得到的是:
barack obamaa restaurantvenice
Run Code Online (Sandbox Code Playgroud)
码:-
$a = array( ' at ', ' in ', ' arriving ', ' a ', ' leaving ', ' walks ', ' walking ', ' her ' );
$str = 'barack obama at a restaurant in venice';
echo str_replace($a,"",$str);
Run Code Online (Sandbox Code Playgroud)
如果我在数组中使用没有空格的单词,结果会非常糟糕:
brck obm resturnt venice
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?