我已经阅读了一些关于在隐藏/最小化应用程序时尝试停止adView的文章,但这会导致我的应用崩溃.
这是我的代码,adView.LoadAd ...和adView.stopLoading都会在启动时崩溃应用程序.
public class MainActivity extends Activity implements OnItemSelectedListener {
@Override
protected void onResume() {
super.onResume();
if (AdViewStarted = true) {
adView.loadAd(new AdRequest());
}
}
@Override
protected void onPause() {
super.onPause();
if (AdViewStarted = true) {
adView.destroy();
}
}
[...]
public class AdMob extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adView = new AdView(this, AdSize.BANNER,"12345678901234567890");
LinearLayout layout = (LinearLayout) findViewById(R.id.adView);
layout.addView(adView);
adView.loadAd(new AdRequest());
AdViewStarted = true;
}
@Override
public void onDestroy() {
if (adView != …Run Code Online (Sandbox Code Playgroud) 我从源代码构建libcrypto.a和libssl.a自己,指定darwin64-x86_64-cc(对于64位)和darwin-i386-cc(对于32位)OpenSSL的配置脚本.
创建了fat库,lipo并将它们作为依赖项添加到我的Xcode项目中.
但是,我得到一个未定义的符号错误:
undefined symbols for architecture x86_64:
"_OPENSSL_ia32cap_P", referenced from:
_AES_cbc_encrypt in libcrypto.a(aes-x86_64.o)
ld: symbol(s) not found for architecture x86_64
Run Code Online (Sandbox Code Playgroud)
注意:使用相同的技术适用于iOS.
lipo -detailed_info libcrypto.a 揭示了:
Fat header in: libcrypto.a
fat_magic 0xcafebabe
nfat_arch 2
architecture i386
cputype CPU_TYPE_I386
cpusubtype CPU_SUBTYPE_I386_ALL
offset 48
size 2700624
align 2^2 (4)
architecture x86_64
cputype CPU_TYPE_X86_64
cpusubtype CPU_SUBTYPE_X86_64_ALL
offset 2700672
size 3938432
align 2^2 (4)
Run Code Online (Sandbox Code Playgroud) 为什么是std::atomic的 store:
std::atomic<int> my_atomic;
my_atomic.store(1, std::memory_order_seq_cst);
Run Code Online (Sandbox Code Playgroud)
在xchg请求具有顺序一致性的商店时执行?
从技术上讲,具有读/写内存屏障的普通商店不应该足够吗?相当于:
_ReadWriteBarrier(); // Or `asm volatile("" ::: "memory");` for gcc/clang
my_atomic.store(1, std::memory_order_acquire);
Run Code Online (Sandbox Code Playgroud)
我明确地谈论x86和x86_64.商店有隐含的获取围栏.
每次我开始我的流,我得到两个MediaPlayer错误.
01-03 12:04:35.738:D/PlayerActivity(10164):play
01-03 12:04:35.742:D/PlayerService(10164):setAudiotStreamType
01-03 12:04:35.742:D/PlayerService(10164): setDataSource
01-03 12:04:35.742:D/PlayerService(10164):prepareAsync
01-03 12:04:35.742:E/MediaPlayer(10164):在状态4
01-03 12:04:35.742:E /中调用MediaPlayer(10164):错误(
-38,0 )01-03 12:04:35.742:D/PlayerService(10164):onPrepared
01-03 12:04:35.742:D/PlayerService(10164):onCreate Service
01-03 12:04:35.750:E/MediaPlayer(10164):错误(-38,0)
01-03 12:04:38.261:D/PlayerService(10164):onPrepared
在Debug标签"play"中,我点击了播放按钮.比调用MediaPlayer服务中的"onCreate",执行"setAudioStreamTpe","setDataSource","prepareAsync",然后执行onPrepared(myMediaPlayer).OnPrepared只执行mp.start().之后记录"onPrepared".然后,在我的服务"onCreate"结束时,会记录"onCreate Service".
为什么有2个onPrepared?!使用mp.prepare()我没有错误.
代码:
@Override
public void onCreate() {
mp = new MediaPlayer();
mp.setOnPreparedListener(this);
prepareMediaPlayer();
onPrepared(mp);
Log.d(TAG, "onCreate Service");
}
public void prepareMediaPlayer()
{
try {
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
Log.d(TAG, "setAudiotStreamType");
mp.setDataSource(PlayerActivity.soundUrl);
Log.d(TAG, "setDataSource");
mp.prepareAsync();
Log.d(TAG, "prepareAsync");
}
catch (IOException e) {}
catch (IllegalArgumentException e) {}
catch (IllegalStateException e) {}
}
@Override
public void onPrepared(MediaPlayer mp) { …Run Code Online (Sandbox Code Playgroud) 我想在IntelliJ中编译ActionBarSherlock作为我的项目的库模块,但是导入import static org.hamcrest.CoreMatchers.equalTo;,import static org.junit.Assert.assertThat;并且import org.junit.Test;无法解析.
任何想法如何解决它?
编辑:当我取消注释ManifestParsingTest.java中ActionBarSherlock,并尝试编译项目中,我得到这些:
Android Dex: [MoneyTracker] UNEXPECTED TOP-LEVEL EXCEPTION:
[...]
Android Dex: [MoneyTracker] 1 error; aborting
Run Code Online (Sandbox Code Playgroud) 我想UIView在我当前画一个CGGraphicsContext.我绘制了UIView通道renderInContext:,但它没有正确定位(始终位于左上角).
我有UIView可用于绘制的所有值UIView.
CGRect frame;
CGRect bound;
CGPoint center;
CGAffineTransform transform;
Run Code Online (Sandbox Code Playgroud)
我目前设置图层的位置和旋转,如下所示:
CGContextTranslateCTM(context, frame.origin.x, frame.origin.y);
CGContextRotateCTM(context, (CGFloat) atan2(transform.b, transform.a));
Run Code Online (Sandbox Code Playgroud)
但由于旋转,该位置不正确并且与原始位置不同.
我该如何恢复原来的位置?坐标系之间没有变化,将问题center.x和center.y价值转化为适合的问题只是一个问题CGContextTranslateCTM.
编辑:
保存的值是正确的,保存正确bounds,center并且transform不是我的问题的起源,我的问题的起源,是将这些值设置为drawable CGLayervia CGContextTranslateCTM.
我想用PayPal iOS SDK进行授权支付,但似乎PayPal忽略了我intent提供的功能.
我'设置intent到authorize
[payment setIntent:PayPalPaymentIntentAuthorize];
Run Code Online (Sandbox Code Playgroud)
但对象总是返回sale付款.
Confirmation: {
"client" : {
"environment" : "mock",
"product_name" : "PayPal iOS SDK",
"paypal_sdk_version" : "2.1.0",
"platform" : "iOS"
},
"response_type" : "payment",
"response" : {
"id" : "PAY-6RV70583SB702805EKEYSZ6Y",
"state" : "approved",
"create_time" : "2014-07-01T17:11:11Z",
"intent" : "sale"
}
}
Run Code Online (Sandbox Code Playgroud)
有任何解决这个问题的方法吗?
我正在尝试用c创建一个简单的扑克游戏Texas Hold'em风格.
起初,我试图用2个char数组创建一副牌.
char *suits_str[4] = {"Spades", "Hearts", "Diamonds", "Clubs"};
char *faces_str[13] = {"2", "3", "4", "5", "6", "7", "8", "9",
"10", "J", "Q", "K", "A"};
Run Code Online (Sandbox Code Playgroud)
一切顺利,代表卡片非常简单.但是当分析手来确定胜利者时,似乎使用char类型值是一个非常糟糕的主意.所以我想将套装改为int值,其中0 = Clubs,1 =钻石,2 = Hearts,3 =黑桃,面部 0 = 2(deuce),1 = 3,11 = King,12 = Ace.(这是我的想法,但我不知道如何将这些字符串值分配给他们)
所以这里有我的阵列,
int suits[4] = {0, 1, 2, 3};
int faces[13] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
Run Code Online (Sandbox Code Playgroud)
但我不知道如何将这些int值转换为匹配的字符串值.我应该使用什么方法?
我有一个像这样的字符串:
String text = number|name|url||number2|name2|url2
现在我写了一个循环
int initialiaze = 0;
for(i = initialize; i > text.length(); i++) {
//do the work
}
Run Code Online (Sandbox Code Playgroud)
在这个循环中我想提取number到一个字符串,name一个字符串,url一个字符串,如果我||做了一个动作(例如将这三个字符串插入db)如果这个动作完成,再次启动一个提取number2,name2并url2进入字符串并做一个动作.
这可能吗?你能告诉我怎么样吗?我不懂.
我想缩小500x500px资源以适应始终由屏幕宽度决定的特定大小.
目前我使用的是Android开发者网站上的代码(有效地加载大型位图),但质量不如我在一个ImageView(作为xml中的源代码)中使用500x500px资源那么好,只是缩放ImageView而不是缩放位图.
但它很慢,我也希望扩展Bitmap内存效率和速度.
编辑:我想缩放的drawable在drawable我的应用程序的文件夹中.
Edit2:我目前的方法.

左图是无需任何修改即可有效加载大位图的方法.中心图像是通过@Salman Zaidi提供的方法完成的,并进行了一些修改:o.inPreferredConfig = Config.ARGB_8888;和o2.inPreferredConfig = Config.ARGB_8888;
右图是一个图像视图,其中图像源以xml定义,我希望用缩放的位图来达到质量.
android ×5
c ×2
c++ ×2
ios ×2
admob ×1
adview ×1
arrays ×1
assembly ×1
bitmap ×1
calayer ×1
cgcontext ×1
database ×1
java ×1
junit ×1
junit4 ×1
lock-free ×1
macos ×1
media-player ×1
onpause ×1
onresume ×1
openssl ×1
paypal ×1
resources ×1
scale ×1
service ×1
split ×1
stdatomic ×1
string ×1
x86 ×1
xcode ×1