开发第二步之启动动画,登入新浪微博,发表微博等

首先看看效果图,目前为大致的效果,细节有待优化。

1.开机动画,小鸟旋转,位移及放大等效果


2.正常显示效果,包括app的图标,版本号,应用名称等。


3.当动画效果结束后会弹出登入窗口。


4.登入进去后的显示,目前为SDK提供的范例页面,没做修改。


5.发表微博


6.到新浪微博页面查看刚刚发表的微博


目前逻辑结构不够严谨,代码不够规范,有待修改。


部分源码介绍:

1.Anim动画效果,小鸟旋转,位移及变大

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">

	<rotate android:fromDegrees="0"
        android:toDegrees="+1080"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="4000"/>
       
     <translate android:fromYDelta="700%" 
         android:toXDelta="0" 
         android:duration="4000" />
     
     <scale android:fromXScale="0"
         android:fromYScale="0"
         android:toXScale="1"
         android:toYScale="1"
         android:duration="4000"/>
</set>

2.界面里引用这个anim特效:

	// 图片往上旋转移动
	public void matrixToTop() {
		imgBTT.setBackgroundResource(R.drawable.bottom_to_top);
		Animation imgBttAni = AnimationUtils.loadAnimation(this,
				R.anim.img_bottom_to_top);
		imgBTT.startAnimation(imgBttAni);
	}

3.判断网络连接是否开启,开启则打开新浪微博认证,没有开启则跳转到setting里的网络设置或者直接退出

public void mainToChange() {
		System.out.println("mainToChange Enter");
		Log.e("kingfly", "psm.isPhoneConnecting=" + psm.isPhoneConnecting(this));
		if (psm.isPhoneConnecting(this)) {
			toOAuthSina();
		} else {
			System.out.println("mainToChange dialog");
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setTitle(getString(R.string.net_alert_dialog_title));
			builder.setMessage(getString(R.string.net_alert_dialog_message));
			builder.setPositiveButton(
					getString(R.string.net_alert_dialog_potitive),
					new DialogInterface.OnClickListener() {

						public void onClick(DialogInterface dialog, int which) {
							// TODO Auto-generated method stub
							Intent intent = new Intent(
									Settings.ACTION_WIFI_SETTINGS);
							ComponentName cName = new ComponentName(
									"com.android.phone",
									"com.android.phone.Settings");
							intent.setComponent(cName);
							startActivity(intent);
						}
					});
			builder.setNegativeButton(
					getString(R.string.net_alert_dialog_negative),
					new DialogInterface.OnClickListener() {

						public void onClick(DialogInterface dialog, int which) {
							// TODO Auto-generated method stub
							// 程序退出事件
							Intent startMain = new Intent(Intent.ACTION_MAIN);
							startMain.addCategory(Intent.CATEGORY_HOME);
							startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
							startActivity(startMain);
							System.exit(0);
						}
					});
			builder.show();
		}
	}

	// 判断手机联网
	public boolean isPhoneConnecting(Context context) {
		try {
			ConnectivityManager manger = (ConnectivityManager) context
					.getSystemService(Context.CONNECTIVITY_SERVICE);
			NetworkInfo info = manger.getActiveNetworkInfo();
			return (info != null && info.isConnected());
		} catch (Exception e) {
			return false;
		}
	}


4.登入新浪微博需要提供的appkey及appsecret,这个只要用户注册了新浪微博开发者就会有个自带的。源码里已删除,还有邮箱登入密码也删除,用户可修改为自己的邮箱来登入,其他的都是可以正常运行。

// 设置appkey及appsecret,如何获取新浪微博appkey和appsecret请另外查询相关信息,此处不作介绍
	private static final String CONSUMER_KEY = "3796329";// 替换为开发者的appkey,例如"1646212960";
	private static final String CONSUMER_SECRET = "fcb46476067fb4664b1c2b5c468f3";// 替换为开发者的appkey,例如"94098772160b6f8ffc1315374d8861f9";


5.开始认证

public void toOAuthSina(){
		
		Weibo weibo = Weibo.getInstance();
		weibo.setupConsumerConfig(CONSUMER_KEY, CONSUMER_SECRET);

		// Oauth2.0
		// 隐式授权认证方式
		weibo.setRedirectUrl("http://www.sina.com");// 此处回调页内容应该替换为与appkey对应的应用回调页
		// 对应的应用回调页可在开发者登陆新浪微博开发平台之后,
		// 进入我的应用--应用详情--应用信息--高级信息--授权设置--应用回调页进行设置和查看,
		// 应用回调页不可为空

		weibo.authorize(RightFFriendActivity.this,
				new AuthDialogListener());
	
	}

6.完整源码下载可参考:

http://download.csdn.net/detail/comkingfly/4189627


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值