安卓接入第三方平台时快速加入第三方Logo

在接入第三方平台时,经常需要加上第三方的Logo启动页,不是每个平台都自己做好的,自己的平台已经有了,再加一个如何好呢?下面介绍一个方便快捷的方法,仅供参考,如有其它高见欢迎大家留言

第一步添加代码

package cn.mygame;


import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;


public class StartView extends Activity {


private static Activity mContext = null;
int iDelayTime = 1000;//延时

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
Resources resources = mContext.getResources();
//获取layout文件夹底下的startview.xml文件的id号
int indentify = resources.getIdentifier(mContext.getPackageName()+":layout/"+"startview", null, null);
setContentView(indentify);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
handler.sendEmptyMessage(1); // 给UI主线程发送消息
}
}, iDelayTime); // 启动等待时间
}


private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
switch (msg.what) {
case 1:
// 切换到主页面
Intent mainIntent = new Intent();
mainIntent.setClass(mContext,MyGame.class);
mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
mContext.startActivity(mainIntent);
mContext.finish();//关闭当前的页面,一定要用finish
overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out); //添加了一个切换淡入淡出的效果
break;
}
}
};
}

第二步:在layout文件下建立你用到的startview.xml

给大家看一下内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:src="@drawable/startview" >
    </ImageView>
</LinearLayout>

第三步:在drawable-hdpi,drawable-ldpi,drawable-mdpi,drawable-xhdpi分别放入图片资源,文件名一定要和你好xml中用到的一样,这里是startview

第四步:在主manifest里添加activity:

        <activity
            android:name="cn.mygame.StartView"
            android:configChanges="keyboardHidden|orientation"
            android:launchMode="standard" //注意模式
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

大概内容都已经贴上来了,大家相互研究一下吧


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值