微信跳转App

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Dream_xiangxiang/article/details/71515798

下载相应的SDK : http://www.openinstall.io/download.html

dependencies {
    compile files('libs/OpenInstall_vX.X.X.jar')
}

在AndroidMaifest.xml中添加权限声明

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

在AndroidMaifest.xml中设置AppKey

<meta-data
        android:name="com.openinstall.APP_KEY"
        android:value="your AppKey" />

初始化SDK

public class MyApplication extends Application {
        @Override
        public void onCreate() {
            super.onCreate();
             OpenInstall.init(this);
             //打开调试,便于看到Log
             OpenInstall.setDebug(true);
        }
}
在AndroidMaifest.xml的唤醒页面activity标签中添加intent-filter

<activity
        android:name=".MainActivity"
        android:launchMode="singleTask">
        <intent-filter>
              <action android:name="android.intent.action.VIEW"/>
              <category android:name="android.intent.category.DEFAULT"/>
              <category android:name="android.intent.category.BROWSABLE"/>
              <data android:scheme="your scheme"/>
        </intent-filter>
</activity>
在应用启动页如下调用相关代码,获取安装参数/渠道参数

public class SplashActivity extends BaseActivity implements AppInstallListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash);
            //获取OpenInstall数据
            OpenInstall.getInstall(this);
    }
    @Override
    public void onInstallFinish(AppData appData, Error error) {
            if (error == null) {
                //获取渠道数据
                Log.d("SplashActivity", "channel = " + appData.getChannel());
                //获取个性化安装数据
                Log.d("SplashActivity", "install = " + appData.getData());
            } else {
                Log.d("SplashActivity", "error : "+error.toString());
            }
    }
}

一键跳转集成  在唤醒页面如下调用相关代码,获取web端传过来的参数

public class MainActivity extends BaseActivity implements AppWakeUpListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            OpenInstall.getWakeUp(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
            super.onNewIntent(intent);
            setIntent(intent);
            //此处要调用,否则App在后台运行时,会无法截获
            OpenInstall.getWakeUp(intent, this);
    }
    @Override
    public void onWakeUpFinish(AppData appData, Error error) {
            if (error == null) {
                Log.d("MainActivity", "wakeup = " + appData.toString());
            } else {
                Log.d("MainActivity", "error : "+error.toString());
            }
    }
}


展开阅读全文

没有更多推荐了,返回首页