Android Studio 学习笔记

Android跳转微信小程序

添加依赖

在build.gradle文件中,添加如下依赖:

dependencies {
implementation 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.3.1'
}

导入class

import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

申请移动应用记录其应用ID

申请时需要应用logo 2828 108108 两个尺寸

签名生成工具
用于获取安装到手机的第三方应用签名的apk包,由com.xxx.xxx生成。
点击下载 签名生成工具

绑定小程序 记录其原始ID

按键跳转

String appId = "wx097c72f6bdbxxxxx"; // 填应用AppId
IWXAPI api = WXAPIFactory.createWXAPI(this, appId);
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
req.userName = "gh_0861359xxxxx"; // 填小程序原始idthis
req.path = path;                  //拉起小程序页面的可带参路径,不填默认拉起小程序首页
req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;// 可选打开 开发版,体验版和正式版
api.sendReq(req);

Android 跳转到其他APP

Intent intent = getPackageManager().getLaunchIntentForPackage("com.aispeech.companionapp");
                if (intent != null) {
                    intent.putExtra("type", "110"); //带参数的跳转
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }

Android activity之间传参

发送端

 Intent intent = new Intent(SoundSearchActivity.this,SoundInputWifiActivity.class);
                Bundle bundle = new Bundle();
                bundle.putParcelable("user", device);
                intent.putExtras(bundle);
                mDeviceScanner.stopScan();
                startActivity(intent);

接收端

Intent intent = this.getIntent();
        bluetooth_device=(BluetoothDevice)intent.getParcelableExtra("user");
        ToastUtils.show(bluetooth_device.getName());

Android imageview 缩放动画

先创建一个scale.xml

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:fillAfter="true"
    android:fillBefore="true"
    android:fromXScale="0.5"
    android:fromYScale="0.5"
    android:interpolator="@android:anim/linear_interpolator"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="-1"
    android:repeatMode="reverse"
    android:startOffset="50"
    android:toXScale="4.0"
    android:toYScale="4.0"/>

再到activity里面

@SuppressLint("ResourceType") ScaleAnimation scaleAnimation = (ScaleAnimation) AnimationUtils.loadAnimation(this, R.xml.scale);
        ImageView move_img.startAnimation(scaleAnimation);

Android 保存本地变量

保存数据

private  SharedPreferences.Editor editor;
private SharedPreferences preferences;

			editor.putString("ip",set_ip);
            editor.commit();

获取数据

editor = getSharedPreferences("data",MODE_PRIVATE).edit();
preferences = getSharedPreferences("data",MODE_PRIVATE);

手动添加申请获取手机号 MAC IMEI信息权限
在这里插入图片描述

new RxPermissions(this).request(Manifest.permission.READ_PHONE_STATE).subscribe(new Consumer<Boolean>() {
            @Override
            public void accept(Boolean aBoolean) throws Exception {
                if (aBoolean) {
                    initUpdate();
                    if (LocationUtil.isOpenLocation(HomeActivity.this)) {
                        startLBS();
                    }
                    SwitchManager.getInstance().init();
                }
            }
        });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值