当前位置:  编程技术>移动开发
本页文章导读:
    ▪headset button 的施用        headset button 的使用 android.permission.BLUETOOTH 权限 MediaButtonIntentReceiver mMediaButtonReceiver = new MediaButtonIntentReceiver();IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);mediaFilter.setPriority(MEDIA_BUTTON_.........
    ▪ iad admob调整代码        iad admob整合代码 #pragma mark iAd - (void)addIAdBanner { // if place the banner on the bottom // adView = [[ADBannerView alloc] initWithFrame:CGRectZero]; adView = [[ADBannerView alloc] initWithFrame:CGRectMake(320 - (32 /.........
    ▪ dither颤动的使用       dither抖动的使用 今天做东西时感觉使用一下抖动效果好看一下,当然有时候不明显,如果你需要看明显的效果的话 就应该方法图片来看 <?xml version="1.0" encoding="UTF-8"?> <bitmap xmlns:andro.........

[1]headset button 的施用
    来源: 互联网  发布时间: 2014-02-18
headset button 的使用

android.permission.BLUETOOTH 权限

MediaButtonIntentReceiver mMediaButtonReceiver = new MediaButtonIntentReceiver();
IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
mediaFilter.setPriority(MEDIA_BUTTON_INTENT_EMPIRICAL_PRIORITY_VALUE);
registerReceiver(mMediaButtonReceiver, mediaFilter);

 

不要忘记设置优先权

 

public class HardButtonReceiver extends BroadcastReceiver

{

@Override

public void onReceive(Context context, Intent intent)

{

Log.v(“TestApp”, “Button press received”);

abortBroadcast();

KeyEvent key = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);

if(key.getAction() == KeyEvent.ACTION_UP)

{

int keycode = key.getKeyCode();

if(keycode == KeyEvent.KEYCODE_MEDIA_NEXT)

{

Log.d(“TestApp”, “Next Pressed”);

}

else if(keycode == KeyEvent.KEYCODE_MEDIA_PREVIOUS)

{

Log.d(“TestApp”, “Previous pressed”);

}

else if(keycode == KeyEvent.KEYCODE_HEADSETHOOK)

{

Log.d(“TestApp”, “Head Set Hook pressed”);

}

}

}

}

 

因为有些按键不一定被映射却要检查


    
[2] iad admob调整代码
    来源: 互联网  发布时间: 2014-02-18
iad admob整合代码

#pragma mark iAd

- (void)addIAdBanner {

    // if place the banner on the bottom

    // adView = [[ADBannerView alloc] initWithFrame:CGRectZero];

    

    adView = [[ADBannerView alloc] initWithFrame:CGRectMake(320 - (32 / 2) - 480 / 2, 480 / 2 - (50 - (32 / 2)), 0, 0)];

    

    adView.frame = CGRectOffset(adView.frame, 32, 0);   // hide

    

    adView.delegate = self;

    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil];

    adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier480x32;

    [[[CCDirector sharedDirector] openGLView] addSubview:adView];

    

    // Transform iAd

    adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

    

    iAdBannerIsVisible = NO;

}


- (void)removeIAdBanner {

    // clear iAd

    adView.delegate = nil;

    [adView removeFromSuperview];

    [adView release];

    adView = nil;

    

    iAdBannerIsVisible = NO;

}


- (void)bannerViewDidLoadAd:(ADBannerView *)banner {

    NSLog(@"[iAd]: Ad did load.");

    

    if (!iAdBannerIsVisible) {

        adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

        

        adView.frame = CGRectOffset(adView.frame, -32, 0);

        

        adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

        

        iAdBannerIsVisible = YES;

    }

    

    if (admobBannerIsVisible) {

        // hide it

        adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

        adMobAd.frame = CGRectMake(140 + 48, 215, 320, 48);

        adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

    }

}


- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {

    NSLog(@"[iAd]: Faild to load the banner: %@", error);

    

    if (iAdBannerIsVisible) {

        adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

        adView.frame = CGRectOffset(adView.frame, 32, 0);

        adView.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

        

        iAdBannerIsVisible = NO;

    }

    

    if (admobBannerIsVisible) {

        // show it

        adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

        adMobAd.frame = CGRectMake(140, 215, 320, 48);

        adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

    }

}


- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {

    NSLog(@"[iAd]: An action was started from the banner. Application will quit: %d", willLeave);

    

    return YES;

}


- (void)bannerViewActionDidFinish:(ADBannerView *)banner {

    NSLog(@"[iAd]: Action finished.");

}

#pragma mark AdMobDelegate methods


- (NSString *)publisherIdForAd:(AdMobView *)adView {

    return @"a14c561cd7cbb82"; // this should be prefilled; if not, get it from  www.admob.com

}


- (UIViewController *)currentViewControllerForAd:(AdMobView *)adView {    

    return controller;

}


- (UIColor *)adBackgroundColorForAd:(AdMobView *)adView {

    return [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; // this should be prefilled; if not, provide a UIColor

}


- (UIColor *)primaryTextColorForAd:(AdMobView *)adView {

    return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor

}


- (UIColor *)secondaryTextColorForAd:(AdMobView *)adView {

    return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor

}


// Sent when an ad request loaded an ad; this is a good opportunity to attach

// the ad view to the hierachy.

- (void)didReceiveAd:(AdMobView *)adView {

    NSLog(@"AdMob: Did receive ad");

    

    adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

    adMobAd.frame = CGRectMake(140, 215, 320, 48);

    adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

    

    if (iAdBannerIsVisible) {

        // if iAdBannerIsVisible, hide admob banner

        adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0));

        adMobAd.frame = CGRectMake(140 + 48, 215, 320, 48);

        adMobAd.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(90));

    }

    

    [[[CCDirector sharedDirector] openGLView] addSubview:adMobAd];

    

    [refreshTimer invalidate];

    refreshTimer = [NSTimer scheduledTimerWithTimeInterval:AD_REFRESH_PERIOD target:self selector:@selector(refreshAd:) userInfo:nil repeats:YES];

    

    admobBannerIsVisible = YES;

}


// Sent when an ad request failed to load an ad

- (void)didFailToReceiveAd:(AdMobView *)adView {

    NSLog(@"field receive admob.");

    

    [adMobAd removeFromSuperview];  

    

    [self performSelector:@selector(requestAd) withObject:nil afterDelay:2.0];

    

    admobBannerIsVisible = NO;

}


- (void)refreshAd:(ccTime)dt {

    NSLog(@"refresh admob.");

    

    [adMobAd requestFreshAd];

}


- (void)requestAd {    

    adMobAd = [AdMobView requestAdWithDelegate:self];

}

1 楼 marshluca 2010-08-12  
不错,如果能放一个开关,通过服务端来控制是使用iAd还是Admob就好了.

    
[3] dither颤动的使用
    来源: 互联网  发布时间: 2014-02-18
dither抖动的使用

今天做东西时感觉使用一下抖动效果好看一下,当然有时候不明显,如果你需要看明显的效果的话 就应该方法图片来看

<?xml version="1.0" encoding="UTF-8"?>
<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="/blog_article/@drawable/b1/index.html"
    android:dither="true" />
<?xml version="1.0" encoding="UTF-8"?>
<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="/blog_article/@drawable/b1/index.html"
    android:tileMode="repeat"
    android:dither="true" />
findViewById(R.id.ImageView01).getBackground().setDither(true);

如果要引用上面的可以设置 drawable来实现,

但是抖动不能直接应用在dialog中,因为里面的背景通常是透明 transparent 的,

可以间接使用getWindow().setFlags(WindowManager.LayoutParams.FLAG_DITHER, WindowManager.LayoutParam


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
java/j2ee iis7站长之家
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3