git使用教程——Mob分享总结

来源:互联网 发布:宁波市软件产业园 编辑:程序博客网 时间:2024/06/06 01:07

git使用教程链接——http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

1、 集成mob的shareSDK流程
注册mob——>创建应用包名必须跟自己工程的一样——>获得对应应用的appkey——>集成自己需要分享的平台——>将文件拷贝到自己的工程——>jar包builder、配置清单文件。
2、分享 集成Mob中的shareSDK
*问题1:集成文件,微信、朋友圈、QQ、Qzone、新浪微博,复制文件配置清单文件,发现微信朋友圈不可以。
解决:1步、appkey 必须变,各大平台的appkey appsecret,最好申请通过。当然有的平台可以绕过审核,例如微信和朋友圈。BypassApproval=true;绕过审核,false不绕过,这是必须在微信开放平台上注册自己的应用。
2步、工程重新打包,因为微信朋友圈必须打包,然后运行打包后的apk,这样就可以了。
 
 
2、 自定义UI,点击按钮访问不同分享平台。
问题:可以跳转到qq界面,但是有失败,虽然报检查网络并重试,但是不是这个问题导致的。
 
解决:原因如下
QQ分享支持图文、音乐分享和QQ授权后分享到腾讯微博
参数说明
title:最多30个字符
text:最多40个字符
private void qq() {
  ShareParams sp = new ShareParams();
  sp.setTitle("优选宝:");
  sp.setTitleUrl("http://baidu.com"); // 标题的超链接
  sp.setText("https://www.youxuanbao.cn");
  // sp.setImageUrl("http://f1.sharesdk.cn/imgs/2014/02/26/owWpLZo_638x960.jpg");
//  sp.setComment("我对此分享内容的评论");
//  sp.setSite(shareParams.getTitle());
//  sp.setSiteUrl(shareParams.getUrl());
  Platform qq = ShareSDK.getPlatform(context, "QQ");
 qq.setPlatformActionListener(platformActionListener);
  qq.share(sp); }
3、 QQ和QQ空间,可以设置分享到网页版和软件版。
ShareByAppClient="false"用网页版,true是用软件版
Qzone空间,返回按钮显示文字,
   sp.setSite("优选宝");//注意这里是 qq空间分享返回按钮,显示“优选宝”
sp.setSiteUrl(shareParams.getUrl());显示“优选宝”
4、 复制链接
ToastUtils.showToast(context, "链接已经复制到剪切板");
     ClipboardManager clipboardManager = (ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE); 
     ClipData myClip;
     String text = "https://www.youxuanbao.cn";
     myClip = ClipData.newPlainText("text", text);
     clipboardManager.setPrimaryClip(myClip);
5、 点击按钮跳转到微信软件
Intent intent = new Intent();
ComponentName cmp = new ComponentName("com.tencent.mm",
"com.tencent.mm.ui.LauncherUI");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(cmp);
startActivityForResult(intent, 0);
新浪微博(编辑界面):com.sina.weibo             com.sina.weibo.EditActivity
腾讯微博(编辑界面):com.tencent.WBlog      com.tencent.WBlog.activity.MicroblogInput
微信:  com.tencent.mm           com.tencent.mm.ui.LauncherUI
QQ:   com.tencent.mobileqq com.tencent.mobileqq.activity.HomeActivity
6、 适配图片,一张图片在不同的手机按比例显示,屏幕width/屏幕height=view.width/view.(height),让图片宽度-屏幕的宽度,然后求出view的高度。
例如: // 根据不同屏幕修改图片的缩放比例。
  int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
  // 屏幕宽(像素,如:480px)
  int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
  // 屏幕高(像素,如:800p) 小屏手机 w=480 h=854
  System.out.println("screenWidth=" + screenWidth + "; screenHeight="+ screenHeight);
  Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.weixin);
  int bwidth = bitmap.getWidth();
  int bheight = bitmap.getHeight();
  System.out.println("图片的h/w==" + bheight / bwidth);
  LayoutParams layoutParams = iv_gwx.getLayoutParams();
  layoutParams.width = screenWidth;
  layoutParams.height = screenWidth * (bheight /bwidth);iv_gwx.setLayoutParams(layoutParams);
9、根据屏幕尺寸动态设置按钮的位置大小
注意事项:线性布局中两个控件,button 和imageview,当button在xml布局中相对于imageview右侧时,代码设置button的宽度不好设置。应去掉改属性
// 设置按钮位置

  LinearLayout.LayoutParams layoutP = (LinearLayout.LayoutParams) btn_gwx.getLayoutParams();
  layoutP.setMargins(screenWidth / 5*3, screenWidth / 4*2-20, screenWidth / 5*2+70, screenWidth / 4*2+15);// 4个参数按顺序分别是左上右下
  btn_gwx.setLayoutParams(layoutP); // mView是控件
xml布局文件如下;
  <RelativeLayout
            android:id="@+id/rl_gwx"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/iv_gwx"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:src="@drawable/weixin" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                 >
                <Button
                    android:id="@+id/btn_gwx"
                    android:layout_width="70dp"
                    android:layout_height="30dp"
                android:background="@android:color/transparent"
                    android:text="" />    
            </LinearLayout>
        </RelativeLayout>
10、不同手机开发时碰到不同效果(原因不知,求大神解答)
*、前提打包签名后的apk,在打开应用程序的时候小米MI和乐视手机letv按Home键程序完全退出。其它把部分牌子手机home键,程序在后台运行
*、前提未打包签名,在eclipse直接运行的程序,说有手机都一样,home键程序运行在后台。  
11、华为mate7,输入交易密码后,返回null;
12、小米note MIUI6.0.1系统,产品中间的布局不显示。

0 0
原创粉丝点击